
46 Cal.Rptr.3d 451 (2006)
141 Cal.App.4th 899
In re V.B., a Person Coming Under the Juvenile Court Law.
The People, Plaintiff and Respondent,
v.
V.B., Defendant and Appellant.
No. B183851.
Court of Appeal of California, Second District, Division Four.
July 26, 2006.
As Modified August 4, 2006.
Nicole Williams, under appointment by the Court of Appeal, for Defendant and Appellant.
Bill Lockyer, Attorney General, Robert R. Anderson, Chief Assistant Attorney General, Pamela C. Hamanaka, Senior Assistant Attorney General, Michael C. Keller and Jack Newman, Deputy Attorneys General, for Plaintiff and Respondent.
EPSTEIN, P.J.
In this case we hold the Superior Court is not estopped from vacating an order placing a minor in a deferred entry of judgment program, pursuant to a plea bargain, where the placement order was made in excess of the court's jurisdiction.

FACTUAL AND PROCEDURAL SUMMARY
The appellant, V.B. (appellant), was arrested for attempted robbery of a fellow middle school student. Appellant was 11 *452 years old at the time. A delinquency proceeding was filed against him pursuant to section 602 of the Welfare and Institutions Code. (All subsequent code citations are to that code unless another is stated.) Two counts were charged: attempted second degree robbery and grand theft from the person (Pen.Code, §§ 664/211, 212.5, subd. (c), and 487, subd. (c)). The probation officer's report, the only factual summary in the record concerning the underlying facts, indicates that two separate crimes were committed: an attempted shakedown robbery at school and a theft committed against the same victim as he was walking home from school.
The parties entered into a plea agreement at the adjudication hearing. Under the terms of that arrangement, appellant pled guilty to the second count, grand theft from the person, the first count (attempted robbery) was dismissed, and the minor was ordered placed into the deferred entry of judgment program under section 790. This plea bargain apparently was offered by the prosecution. It was accepted by appellant personally and through his attorney, and by the court. The trial court presided over a detailed explanation of appellant's rights and waivers of those rights before accepting the plea. The transcript of the proceeding does not reflect any discussion that, as a minor under 14, appellant was not eligible for the program. He was placed in the program, and he agreed to obey several conditions of probation, including terms aimed at improving his performance at school, and enrollment and completion of specified programs. He was released to the care of his grandmother.
Subsequent progress reports showed substantial improvement in appellant's performance at school, both in terms of grades and attendance. He was participating in the ordered programs. At subsequent periodic reviews, all orders, including the order placing him in the deferred entry of judgment program, were continued in full force and effect.
This state of affairs continued until the May 3, 2005 hearing. By that time, the trial judge (a different bench officer than the referee who had accepted the plea bargain) had discovered that appellant was ineligible to participate in the deferred entry of judgment program because he was under 14 at the time of the plea bargain and order admitting him into the program. Section 790, subdivision (a)(5) provides that, to be eligible, the minor must be at least 14 years of age at the time of the hearing. The hearing was held on May 3, 2004. Appellant was born on June 29, 1992, and hence was still 11 at that time.
The trial judge explained that placing appellant in the deferred entry of judgment program was a mistake that could not remain uncorrected. The court proposed to leave him in home-on-probation status with his grandmother until he completed his community service obligation, and to then place him home on probation without a declaration of wardship. Once he completed all conditions of probation the court would terminate jurisdiction and consider dismissing the petition. The court observed that this was what appellant would have attained under the deferred entry of judgment program.
Appellant's attorney argued that the benefits were not exactly the same; under the deferred entry of judgment program, his record would have been automatically sealed upon completion of the program; otherwise he would have to wait until his 18th birthday to seek a sealing order.
The court recognized that ineligibility for the deferred entry of judgment program would result in a delay to the time when appellant could receive a sealing order *453 with respect to the record for the present charges. But it found no escape from the basic problem: appellant was not eligible to be in the program, and ordering him into it was not only a mistake but also an action taken in excess of the court's jurisdiction. The court rejected appellant's argument that the court itself was estopped to raise that issue. It saw only two alternatives: appellant could withdraw his plea and begin over, or he could accept the short home-on-probation alternative outlined by the court. The prosecutor neither supported nor opposed the court's intended ruling; he simply submitted the matter without comment.
Appellant's attorney said his client would choose to withdraw his plea and begin over, and would file a motion to do so. The record does not reflect that such a motion was filed, let alone acted upon. The court vacated its earlier order placing appellant in the deferred entry of judgment program. By the time of the next hearing, appellant had completed all the conditions of probation. The court ordered him home on probation and terminated jurisdiction over the case.
Appellant filed a timely notice of appeal from the May 3, 2005 order vacating the order that had placed him in the deferred entry of judgment program.

DISCUSSION
Sections 790-795 (comprising article 20.5, a part of chapter 2, part I, division 2 of the Code), were enacted by initiative as part of Proposition 21, the Gang Violence and Juvenile Crime Prevention Act of 1998. This measure was approved by voters at the March 2000 election. The new statute provides that "in lieu of jurisdictional and dispositional hearings, a minor may admit the allegations contained in a section 602 petition and waive time for the pronouncement of judgment. Entry of judgment is deferred. After the successful completion of a term of probation, on the motion of the prosecution and with a positive recommendation from the probation department, the court is required to dismiss the charges. The arrest upon which judgment was deferred is deemed never to have occurred, and any records of the juvenile court proceeding are sealed. [Citations.]" (Martha C. v. Superior Court (2003) 108 Cal.App.4th 556, 558, 133 Cal.Rptr.2d 544.) The probation officer makes a recommendation as to whether the minor can be benefited by placement in the program. This is based on factors such as the minor's age, maturity, educational background, family relationship, treatment history (if any) and any mitigating and aggravating factors. But the final decision is by the court. (§ 791, subd. (b); Martha C., supra, 108 Cal.App.4th at p. 562, 133 Cal.Rptr.2d 544.)
An uncodified provision of the initiative states that its purpose is to form a part of a comprehensive juvenile justice reform package aimed at early intervention of at risk youth, utilizing efforts that emphasize "rehabilitative protocols over incarceration" and requiring that first-time non-violent juvenile felons appear in court, admit guilt for their offenses, be held accountable, but also be given a non-custodial opportunity to demonstrate through good conduct and compliance with court-monitored treatment and supervision that the record of the offense "should justly be expunged." (Subd. (j) of findings and declarations.)
There are six specific prerequisites for eligibility, each of which must be satisfied for the minor to be allowed to participate in the program. Section 790, subdivision (a) provides:
"Notwithstanding Sections 654, 654.2, or any other provisions of law, this article *454 shall apply whenever a case is before the juvenile court for a determination of whether a minor is a person described in Section 602 because of the commission of a felony offense, if all of the following circumstances apply:
"(1) The minor has not previously been declared to be a ward of the court for the commission of a felony offense.
"(2) The offense charged is not one of the offenses enumerated in subdivision (b) of Section 707.
"(3) The minor has not previously been committed to the custody of the Youth Authority.
"(4) The minor's record does not indicate that probation has ever been revoked without being completed.
"(5) The minor is at least 14 years of age at the time of the hearing.
"(6) The minor is eligible for probation pursuant to Section 1203.06 of the Penal Code."
As we have seen, the critical criterion in this case is the fifth, requiring that the minor be at least 14 years old at the time of "hearing," a term we understand to mean the hearing at which the minor is ordered into the program. As we also have seen, appellant did not meet that criterion. The action of the court in ordering him into the program was in direct contravention of the initiative, and was in excess of its jurisdiction. (See People v. Hester (2000) 22 Cal.4th 290, 295, 92 Cal. Rptr.2d 641, 992 P.2d 569.) Neither side disputes the conclusion that the order placing appellant in the deferred entry of judgment program was in excess of jurisdiction. There also is no dispute but that the court did not exceed its "fundamental jurisdiction": jurisdiction over the parties and the subject, a distinction recognized at least since Abelleira v. District Court of Appeal (1941) 17 Cal.2d 280, 288, 109 P.2d 942; People v. Beebe (1989) 216 Cal.App.3d 927, 932, 265 Cal.Rptr. 242 (order approving plea authorizing reduction of straight felony to misdemeanor after successful completion of probation was in excess of jurisdiction but was not taken in absence of fundamental jurisdiction).
Since the court had fundamental jurisdiction, appellant invokes the doctrine of judicial estoppel as a basis to uphold the original order and overturn the later order vacating appellant's placement in the program. The focus of his argument, at least as presented to the court and in his opening brief, is that the court is estopped from vacating the order because he was entitled to the benefit of his bargain. Here again, the parties do not dispute the underlying facts, although they differ on their consequences. Under the program, appellant would have been entitled to automatic sealing of his record upon successful completion of all the probation requirements. Absent the special benefit of section 791, however, he would not be entitled to automatic sealing of his records and was not authorized to petition for that relief until five years had passed from termination of probation, or upon reaching age 18. (§ 781, subd. (a).) That is the detriment upon which appellant relies to invoke the doctrine of judicial estoppel.
In criminal jurisprudence that doctrine most commonly has been applied to estop a defendant (or minor in a case arising out of a section 602 adjudication) from attacking orders imposed under a plea bargain to which he agreed. The action of a defendant, or minor, to have the advantage of the bargain yet attack its provisions as unauthorized by law, amounts to trifling with the court, a tactic courts do not countenance. (See People v. Hester, supra, 22 Cal.4th 290, 295, 92 Cal.Rptr.2d 641, 992 P.2d 569; People v. Chatmon (2005) 129 Cal.App.4th 771, 773, 28 Cal.Rptr.3d 859; *455 People v. Flood (2003) 108 Cal.App.4th 504, 508, 133 Cal.Rptr.2d 516; People v. Mendez (1991) 234 Cal.App.3d 1773, 1781, 286 Cal.Rptr. 216.) Appellant argues, in essence, that what's sauce for the goose should be good for him as well: all parties to the plea bargain should be estopped from arguing an infirmity based on a judicial act in excess of jurisdiction, so long as the court had fundamental jurisdiction.
Respondent replies that it finds no case in which the doctrine has been applied against the prosecution, much less, as appellant urges here, against the court.
A fairly recent decision, People v. Watts (1999) 76 Cal.App.4th 1250, 91 Cal.Rptr.2d 1, explores the issue in detail. In that case, two defendants, Shaw and Watts, were charged with several counts of attempted and completed armed robberies. Shaw was tried first, some years before the trial of Watts. In the Shaw trial the prosecutor successfully pursued the theory that Shaw personally used a firearm against one of the victims. At the trial of Watts, the prosecutor, acting at least in part on new evidence, successfully argued it was Watts who wielded the weapon. In reviewing Watts's conviction, the court first rejected the claim of a due process violation, noting the absence of any suggestion that the prosecutor manipulated evidence at the Watts trial. (Id. at p. 1261, 91 Cal.Rptr.2d 1.)
The court then turned to the claim of judicial estoppel, a doctrine which "essentially acts to prevent a party from abusing the judicial process by advocating one position, and later, if it becomes beneficial to do so, asserting the opposite. The doctrine is designed not to protect any party, but to protect the integrity of the judicial process. [Citation.]" (People v. Watts, supra, 76 Cal.App.4th at pp. 1261-1262, 91 Cal.Rptr.2d 1.) The court noted the observation of others that judicial estoppel has not been applied against the prosecution in criminal actions, and that neither party cited, nor did it find, authority for the proposition that it should apply against the prosecution. (Id. at p. 1262, 91 Cal. Rptr.2d 1.) Nor ought it apply to "prevent the state from taking inconsistent positions in separate proceedings, or at least it should not do so absent some indication that misconduct on the part of the prosecutor was a cause of the inconsistency." (Id. at p. 1263, 91 Cal.Rptr.2d 1.) Summing up, the court concluded that "the integrity of the judicial process is not compromised by the prosecution of two individuals for the same crime when there is probable cause to support the charges against each individual." (Id. p. 1264, 91 Cal.Rptr.2d 1.)
The court also discussed the related doctrine of collateral estoppel, which does not prevent relitigation in a criminal case of an issue decided in an earlier criminal action brought against a different defendant. (People v. Watts, supra, 76 Cal.App.4th at p. 1263, 91 Cal.Rptr.2d 1.) Subsequent developments have qualified that conclusion in cases of prosecutorial bad faith. (See In re Sakarias (2005) 35 Cal.4th 140, 156, 160, 25 Cal.Rptr.3d 265, 106 P.3d 931 [due process violated where prosecutor "intentionally and in bad faith" sought conviction or death sentence for two defendants on the basis of acts for which only one person could be responsible]; and see Bradshaw v. Stumpf (2005) 545 U.S. 175, 125 S.Ct. 2398, 162 L.Ed.2d 143 [certiorari granted on similar issue but issue was not ripe for decision; court expressed no opinion whether prosecutor's actions were a due process violation or were prejudicial].)
Another related doctrine, equitable estoppel ("estoppel in pais"), has been applied against the government "where justice and right require it." But even this form of estoppel is not be applied against *456 the government "if to do so would effectively nullify a `strong rule of policy, adopted for the benefit of the public, ...' [Citation.]" (City of Long Beach v. Mansell (1970) 3 Cal.3d 462, 493, 91 Cal.Rptr. 23, 476 P.2d 423.)
Assuming that in a proper case the prosecutor may be subject to judicial estoppel, this is not that case, nor is there any basis to estop the court. Treating the latter first, we find no reason to preclude a court from taking corrective action to cure an order taken in excess of its authority, so long as the court still has jurisdiction over the cause and parties. This is a case where the trial court acted in error. We do not know whether the parties or the court were aware that appellant was not eligible for the program before the plea by which he was ordered into it was accepted. There were ample signs of his ineligibility in the record: the original probation report stated that he was ineligible due to his age, and his age was noted in several of the materials before the court. Nevertheless, the point may have been overlooked. It almost certainly was overlooked by the bench officer who ultimately ruled on the point when, at a previous nonappearance review, she directed that all orders remain in full force and effect. In any event, the responsible course for the trial court to take upon becoming aware of the error is to correct it. That is what the court did. It also was appropriate for the court to do so in a manner that gave appellant as much of the benefit of his previous bargain as the law allows. In continuing appellant home on probation and terminating jurisdiction as soon as he completed the programs he was in, the court did that as well.
We find no basis to fault the trial court's corrective action, much less to apply an estoppel doctrine to that action.
Perhaps recognizing the problems in trying to judicially estop the court, in his reply brief, appellant tries to estop the Attorney General from opposing his appeal. The implication is that the prosecutor could have been estopped and that the Attorney General, by representing the People on appeal, steps into that officer's shoes. It is true that, with respect to estoppel, the Attorney General acts as prosecutor, much as the District Attorney did in the trial court. (People v. Beebe, supra, 216 Cal.App.3d at p. 933, 265 Cal. Rptr. 242.) But there is no reason to estop him from presenting his arguments to the court. First, as we have seen, while the prosecutor may have initiated the plea bargain offer and certainly was a party to it, once the trial court pointed out its infirmity, the prosecutor simply submitted the matter. More fundamentally, the State has a strong interest in seeing to it that defendants do not manipulate the system to obtain punishment less than what could have been imposed under the applicable statutes. Here, appellant minor obtained dismissal of the more serious count, attempted robbery, in exchange for his plea to the theft count, agreement to the conditions of the plea bargain, and placement in the program. He is not arguing that he should be allowed to begin anew with the original charges; the trial court offered that option, and he did not take it up. While he will not be able to obtain a sealing order for some time beyond the time that would have applied under the deferred entry of judgment program, he will be able to apply for it in a few years. Beyond that, he appears to have benefited from the programs in which he participated as conditions of probation, and, hopefully, has learned from them.
Even under the more lenient doctrine of equitable estoppel, there is no basis to estop the prosecutor or the Attorney General. There is an important public interest issue here. First, there is vindication *457 of the line the voters have drawnthe 14-year minimum age requirement. More fundamentally, there is the rule and expectation that courts follow the law and do not lend themselves to a blatant disregard of that law. Where a trial court is asked to approve an illegal plea bargainillegal because it violates a policy condition established by the Legislature or the people through the initiative processthe proper course of action for the court is clear. It should decline to act in excess of its authority and should refuse to approve an arrangement under which it is called upon to do so. Were it otherwise, any number of valid legislative restrictions on plea bargains and programs could be gainsaid by an agreed-upon resolution that is in blatant violation of law, or by a wink and a nod. Neither is proper conduct for a bench officer, and the trial judge in this case acted with full propriety in vacating the illegal order.

DISPOSITION
The order vacating the previous order admitting V.B. into the section 790 deferred entry of judgment program is affirmed.
MANELLA and SUZUKAWA, JJ., concur.
