OPINION OF THE COURT
Simons, J.The question presented on this appeal is whether defendant’s sentence as a second felony offender may be predicated upon a 1971 conviction which satisfied constitutional standards when obtained and has survived postconviction collateral attack, but was obtained by means which, if the indictment were tried now, would violate defendant’s rights under the Sixth Amendment of the United States Constitution as presently applied by the courts. Defendant asserts that the prior conviction may not be used to enhance his sentence because in obtaining it the trial court followed a practice of closing the courtroom which this court subsequently recognized as unconstitutional. We disagree: for purposes of determining whether a prior conviction "was unconstitutionally obtained” (CPL 400.21 [7] [b]) — and thus may not be counted for predicate felony purposes — the proper inquiry is to determine whether the conviction was obtained in violation of the defendant’s rights as defined by the law at the time of the conviction or by present law which is properly applied to it under recognized principles of retroactivity.
On March 5, 1971 defendant, then a New York City police officer, sold 50 packets of heroin to an undercover police officer. He was arrested six days later, possessing heroin and methadone, and subsequently convicted of various drug-related felonies arising from the two incidents. During trial, the People called as a witness the undercover officer who made the "buy” from defendant. Before the officer testified, the prosecutor requested that the court take judicial notice of the hazards to which testifying undercover officers are generally subject and requested that spectators be excluded. The trial court summarily closed the courtroom to the public before the officer testified. Defendant appealed his conviction, contending that it had been obtained in violation of his constitutional right to a public trial. His claim was rejected by both the Appellate Division (41 AD2d 968) and this court (36 NY2d 192).
Four years later we declared for the first time that the summary closing of a courtroom simply because a witness is *644an undercover police officer constitutes reversible error (People v Jones, 47 NY2d 409, cert denied 444 US 946). Deviation from the rule is justified, we said, only when preceded by an inquiry "careful enough to assure the court that defendant’s right to a public trial is not being sacrificed for less than compelling reasons.” (Id., at 414-415.) There had been no such inquiry in defendant’s case.
In 1986, defendant was convicted in this case on his guilty plea of attempted robbery in the second degree in satisfaction of an indictment charging him with several crimes for his participation in an armed robbery and subsequent gun battle with the police. He was sentenced as a second felony offender over his objection that the 1971 conviction, used as the predicate, was unconstitutionally obtained under People v Jones (47 NY2d 409, supra). After sentencing, defendant moved pursuant to CPL 440.10 (2) (a) to vacate the 1971 conviction as unconstitutional, urging that the Jones rule should be applied retroactively. The court denied the petition and defendant did not appeal that ruling.
On this appeal, defendant pursues a different route to avoid being sentenced as a predicate felon. He now concedes that Jones should not be applied retroactively to vacate the 1971 conviction. Instead, he argues that the Jones rule should only be applied to prevent the imposition of enhanced punishment for the 1986 conviction. The Appellate Division affirmed the judgment of conviction but, analyzing defendant’s claim solely as whether the Jones rule should be applied retroactively and required vacatur of the 1971 conviction, did not address defendant’s primary argument.
A conviction obtained in violation of one’s constitutional rights may not be used to enhance punishment for a later offense (Burgett v Texas, 389 US 109, 115). CPL 400.21 (7) (b) implements that principle. It provides in relevant part: "A previous conviction in this or any other jurisdiction which was obtained in violation of the rights of the defendant under the applicable provisions of the constitution of the United States must not be counted in determining whether the defendant has been subjected to a predicate felony conviction. The defendant may, at any time during the course of the hearing hereunder controvert an allegation with respect to such conviction in the statement on the grounds that the conviction was unconstitutionally obtained” (emphasis added).
The clear import of the phrases "was obtained” and "was *645unconstitutionally obtained” indicate that the validity of the conviction shall be determined as of the time it was entered. An unconstitutional conviction is, by definition, a conviction which was obtained in violation of the defendant’s constitutional rights, i.e., his rights as defined by the law existing at the time the conviction was obtained or by subsequent law applicable to the judgment under principles of retroactivity. The conviction does not become unconstitutional merely because the law has changed subsequent to the defendant’s direct appeal of that conviction (Linkletter v Walker, 381 US 618, 628-629; see also, United States v Johnson, 457 US 537, 542). Since the predicate felony statute operates upon the prior conviction rather than the prior practice, accepted principles of retroactivity must be applied to determine whether a conviction "was unconstitutionally obtained” and thus may not be counted when the People seek to impose an enhanced sentence. Under those rules, a defendant is entitled to the benefit of any change in the law if the change occurs before his conviction becomes final (see, Griffith v Kentucky, 479 US 314, 328) or, if the right at stake is such that the law has engrafted an exception to the traditional rule to permit collateral attack on judgments of conviction after they have become final (see, e.g., Robinson v Neil, 409 US 505 [double jeopardy]; Ashe v Swenson, 397 US 436 [same]; Arsenault v Massachusetts, 393 US 5 [right to counsel at a preliminary hearing]; McConnell v Rhay, 393 US 2 [right to counsel at sentencing]; Roberts v Russell, 392 US 293 [right to confrontation]; Jackson v Denno, 378 US 368 [right to pretrial determination of the voluntariness of a confession]).
Defendant’s 1971 conviction, which serves as the predicate for his present sentence, meets neither of these criteria. It was not "obtained in violation of the rights of * * * defendant” because the closure of the courtroom during his trial complied with the existing legal requirements for a public trial (see, People v Hinton, 31 NY2d 71, cert denied 410 US 911; People v Hagan, 24 NY2d 395, cert denied sub nom. Hayer v New York, 396 US 886; People v Jelke, 308 NY 56). We so held on defendant’s direct appeal (People v Catalanotte, 36 NY2d 192, affg 41 AD2d 968). That we subsequently declared a similar procedure unconstitutional in People v Jones (47 NY2d 409, supra) does not, as defendant concedes, make the Jones rule retroactive to prior convictions that have survived direct appeal, nor does it, in view of the plain language of the *646statute, require a finding that the predicate conviction "was unconstitutionally obtained”.
The logic of such an interpretation is manifest when one considers that the proper meaning to be given to broadly stated constitutional commands, such as due process of law and right to a public trial, changes constantly. To apply such changes retroactively when the court has not declared them retroactive, may open to question hundreds of convictions and enhanced sentences based upon them (see, e.g., Batson v Kentucky, 476 US 79 [racial bias in jury selection]; Payton v New York, 445 US 573. [warrantless felony arrest in home]; Sandstrom v Montana, 442 US 510 [improper jury charge]; Griffin v California, 380 US 609 [comment by prosecutor or Judge upon defendant’s failure to testify]). The dissent assumes such convictions and others like them were unconstitutionally obtained even though they concededly cannot be vacated in postconviction proceedings. It holds that no matter how drastically the law has been modified between the time of the first conviction and the second, any change renders the first conviction unconstitutional for the purpose of enhanced sentencing. Its rule would invalidate the conviction for such purpose even if the infirmity was not challenged at the time of the first conviction because under current law, if the predicate conviction "was unconstitutionally obtained”, the defendant does not have to raise the constitutional deprivation on direct appeal from the first conviction (see, People v Harris, 61 NY2d 9, 16; People v Wright, 119 AD2d 973). A defendant would not be required to anticipate a future change in the law as did the defendant in this case. For example, and using the illustrations cited above, under the dissent’s view, past convictions obtained by a jury selected along racial lines would be open to question, at least for enhanced sentencing purposes, even though constitutional rules in effect at the time were followed by the trial court (compare, Swain v Alabama, 380 US 202; and People v McCray, 57 NY2d 542, with Batson v Kentucky, 476 US 79, supra). Similarly, convictions obtained through the use of confessions or real evidence properly obtained under existing law, but now open to question in view of Payton (supra), and convictions obtained after trials in which Sandstrom charges were given would be nullified for enhanced sentencing purposes, regardless of whether defendant objected at trial. The statute does not require this result, nothing indicates the Legislature intended it and there are no policy reasons for ordering it.
*647Finally, we note that People v Love (71 NY2d 711), relied upon by the defendant and the dissent, is clearly distinguishable. In that case the defendant’s prior conviction was vacated because it was obtained in violation of his constitutional rights under the law that existed at the time of the conviction. Here, defendant’s constitutional rights, as then defined, were respected in full.
Accordingly, the order of the Appellate Division, insofar as appealed from, should be affirmed.