
67 Cal.Rptr.3d 403 (2007)
156 Cal.App.4th 561
The PEOPLE, Plaintiff and Respondent,
v.
Idalberto SAAVEDRA, Defendant and Appellant.
No. D049187.
Court of Appeal of California, Fourth District, Division One.
October 29, 2007.
*405 Appellate Defenders, Inc., and William D. Holman, under appointment by the Court of Appeal, San Diego, for Defendant and Appellant.
Edmund G. Brown, Jr., Attorney General, Dane R. Gillette and Gary W. Schons, Assistant Attorneys General, Lilia E. Garcia and Raquel M. Gonzalez, Deputy Attorney's General, for Plaintiff and Respondent.
*404 HALLER, J.
Idalberto Saavedra appeals from a judgment convicting him of possessing a weapon while confined in a penal institution. (Pen.Code,[1] § 4502, subd. (a).) He contends the trial court erred by failing to sua sponte instruct on duress and self-defense. Alternatively, he contends defense counsel provided ineffective representation by failing to request instructions on these two defenses.
We reject Saavedra's contention that the evidence supported a duress instruction. We agree with his assertion that self-defense may be a valid defense to a charge of inmate weapon possession, but find the omission of the instruction in this case to be harmless. Based on these holdings, Saavedra's ineffective representation claim also fails. We affirm the judgment.

FACTUAL AND PROCEDURAL BACKGROUND
On June 1, 2005, Saavedra, an inmate at Centinela State Prison (Centinela), was attacked by two other inmates in the prison yard. Responding to the altercation, the prison officials ordered all inmates in the yard to assume a sitting position on the ground. Officer Enrique Rosiles observed that the two inmates were punching Saavedra in the upper torso with closed fists. *406 Saavedra was first standing and then sitting on the ground; his arms were raised upwards trying to deflect the blows. Officer Christopher Knight ordered the inmates to "get down," and threatened to spray the two assailants with pepper spray if they did not stop the attack. When the assailants did not comply with his orders, Officer Knight sprayed them. In response, the assailants, as well as Saavedra, laid down on the ground.
As a result of the attack, Saavedra was bleeding from his nostril and lower lip and his dentures had been knocked out. He had scrapes and bruises on his forehead, back and neck, a cut near his eye, and a cut on his hand. He appeared dazed and complained he was having difficulty breathing. He was taken to the medical clinic on the yard, where he was given an oxygen mask.
After being examined at the clinic, Saavedra was taken by stretcher to the central health center for further care. At the central health center, Saavedra was searched by Officer Henry Rosas. Inside Saavedra's shoe, Officer Rosas found an inmate-manufactured weapon, consisting of a single razor blade attached by masking tape to a shaving razor handle. The razor blade was wrapped in tissue paper.
Officer Rosas tried asking Saavedra questions but Saavedra appeared to be in so much pain that he could not answer. However, Saavedra was conscious and able to communicate with medical staff about his breathing difficulties, and his condition improved when he was at the central health unit. According to Officer Rosas, Saavedra never mentioned that he had a weapon in his shoe.
Testifying on his own behalf, Saavedra claimed that he seized the weapon when one of his assailants dropped it during the attack. He explained that as he was walking across the yard, he felt someone hit him in the back. As the two men hit him, he tripped one of the assailants so the assailant would fall on the ground. Saavedra then got on top of the assailant and started hitting him. As this assailant fell to the ground, Saavedra saw a weapon fall from the man's body, perhaps from his hand or pocket. Saavedra testified that he picked up the weapon and placed it in his shoe by the side of his foot. When asked if his assailant tried to pick up the weapon, Saavedra answered no, stating: "No. At that time the other one, this one, was trying to help him get up. And this one was also swinging at me. So I was on my knees on the ground. I picked up the weapon and put it in my shoe...." After the assailant on the ground got up, both attackers continued to hit Saavedra, who never managed to get up from the ground.
Saavedra testified that when he seized the weapon, all he was thinking about was defending himself, and he was worried that if his attackers got the weapon back they would use it to "cut [his] throat." However, he did not use the weapon to fight off the two attackers "[b]ecause [he] [did not] want to see anymore blood shed."
Saavedra testified that after the fight stopped he did not tell the officers about the weapon because his "mind was gone" from the impact of the blows, and he was having difficulty breathing because he had inhaled some of the pepper spray. He stated he did not disclose the weapon right away because he was unconscious; that had he been fully conscious he would have disclosed it sooner; and that he did disclose the weapon as soon as he was conscious. He explained that when the officer started searching him, he "became a little conscious" and at this point first told the officer there was a weapon in his shoe.
Based on the defense evidence showing that Saavedra picked up the weapon during *407 the fight, the trial court instructed the jury on the defense of necessity. Defense counsel did not request instructions on duress or self-defense.

DISCUSSION
Saavedra contends that in addition to instructing the jury on the defense of necessity, the trial court should have sua sponte instructed on the defenses of duress and self-defense, or that his counsel should have requested these instructions. He asserts the failure to give these instructions created reversible error because the prosecution has the burden to disprove duress and self-defense beyond a reasonable doubt, whereas the defendant has the burden to prove necessity by a preponderance of the evidence.
A trial court has a sua sponte duty to instruct regarding a defense if there, is substantial evidence to support the defense and it is not inconsistent with the defendant's theory of the case. (People v. Montoya (1994) 7 Cal.4th 1027, 1047, 31 Cal.Rptr.2d 128, 874 P.2d 903.) In deciding whether there is substantial evidence, "the trial court does not determine the credibility of the defense evidence, but only whether `there was evidence which, if believed by the jury, was sufficient to raise a reasonable doubt....'" (People v. Salas (2006) 37 Cal.4th 967, 982, 38 Cal.Rptr.3d 624,127 P.3d 40.)

Duress
Duress is available as a defense to defendants who commit a crime "under threats or menaces sufficient to show that they had reasonable cause to and did believe their lives would be endangered if they refused." (§ 26, subd. 6; People v. Otis (1959) 174 Cal.App.2d 119, 124-125, 344 P.2d 342.) An essential component of this defense is that the defendant be faced with a direct or implied demand that he or she commit the charged crime. "The defense of duress, unlike the necessity justification, requires that the threat or menace be accompanied by a direct or implied demand that the defendant commit the criminal act charged." (People v. Steele (1988) 206 Cal.App.3d 703, 706, 253 Cal. Rptr. 773 [duress not available as a defense when inmate escaped in response to threats of bodily injury because persons making threats did not demand that defendant escape].) In contrast, the necessity defense is available when the defendant reasonably believed there was a threat of harm and no other means to alleviate the harm, and the harm sought to be avoided by the defendant's conduct was greater than the harm sought to be prevented by the law defining the charged offense. (People v. Coffman and Marlow (2004) 34 Cal.4th 1, 100, 17 Cal.Rptr.3d 710, 96 P.3d 30; People v. Patrick (1981) 126 Cal. App.3d 952, 960, 179 Cal.Rptr. 276; People v. Richards (1969) 269 Cal.App.2d 768, 777, 75 Cal.Rptr. 597.)
Here, the facts supported a necessity defense based on the theory that Saavedra seized the weapon to prevent a more aggravated attack against him, which outweighed the harm sought to be prevented by forbidding prison inmates from possessing weapons. The facts did not support a duress defense because there are no facts showing an express or implied demand by Saavedra's attackers that he seize the weapon. Accordingly, the trial court was not required to instruct on the defense of duress.

Self-defense
The Attorney General argues that self-defense should not be available as a defense to a charge of possession of a weapon by an inmate, because the offense does not require proof of the inmate's intent or purpose for possessing the weapon. *408 It is well established that a prison inmate charged with a violation of section 4502 cannot raise the defense of self-defense based on a claim that a weapon was possessed for protection from an anticipated, future attack. (People v. Crenshaw (1946) 74 Cal.App.2d 29-30, 167 P.2d 781; People v. Velasquez (1984) 158 Cal.App.3d 418, 420, 204 Cal.Rptr. 640.) However, the courts have recognized in dicta that it may be permissible for an inmate to raise a narrow claim of self-defense when the inmate was "confronted with an emergency that ... justified his seizing one of the prohibited weapons in order to protect himself." (People v. Crenshaw, supra, 74 Cal.App.2d at p. 30, 167 P.2d 781, italics added; People v. Evans (1969) 2 Cal. App.3d 877, 881-882, 82 Cal.Rptr. 877, disapproved on other grounds in People v. King (1978) 22 Cal.3d 12, 25, 148 Cal.Rptr. 409, 582 P.2d 1000; People v. Steely (1968) 266 Cal.App.2d 591, 595-596, 72 Cal.Rptr. 368; People v. Purta (1968) 259 Cal. App.2d 71, 74, 66 Cal.Rptr. 38; People v. Velasquez, supra, 158 Cal.App.3d at pp. 420-421, 204 Cal.Rptr. 640.) As stated by the Velasquez court, "self-defense might justify violation of the statute where the prisoner was under imminent mortal attack, had no opportunity to seek protection of the authorities, and temporarily seized a prohibited weapon in order to save his life." (Velasquez, supra, at pp. 420-421, 204 Cal.Rptr. 640.)
A rule precluding reliance on self-defense when an inmate arms himself or herself in anticipation of an attack is consistent with the general principle that self-defense operates as a defense only when the threat of bodily harm is immediate and present; fear of harm even in the near future is insufficient. (People v. Humphrey (1996) 13 Cal.4th 1073, 1082, 56 Cal. Rptr.2d 142, 921 P.2d 1.) Further, a concomitant rule allowing an inmate to raise self-defense when he or she temporarily seizes a weapon as a protective measure in response to an emergency is consistent with the established rule that a convicted felon charged with possession of a firearm may raise self-defense if the firearm only became available during an emergency and was possessed temporarily in response to the emergency and there was no other means of avoiding the danger. (People v. King, supra, 22 Cal.3d at p. 24, 148 Cal. Rptr. 409, 582 P.2d 1000; see § 12021, subd. (h)(1)(A), (B) [convicted felon's possession of firearm justifiable if convicted felon "found the firearm or took the firearm from a person who was committing a crime against him or her" and "possessed the firearm no longer than was necessary to deliver or transport the firearm to a law enforcement agency"].)[2]
We conclude that allowance of a narrow self-defense claim as suggested in cases such as Crenshaw and Velasquez represents a correct balancing of the policy concern that prison inmates be strictly forbidden from possessing weapons (People v. Brown (2000) 82 Cal.App.4th 736, 739-740, 98 Cal.Rptr.2d 519), and the firmly established principle that a person acting in self-defense is not criminally culpable (People v. King, supra, 22 Cal.3d at pp. 22-23, 148 Cal.Rptr. 409, 582 P.2d 1000).
We agree with Saavedra that there was substantial evidence to support self-defense based on a theory that he temporarily seized the weapon because of a fear of immediate harm. The evidence showed Saavedra was being beaten by two inmates. Saavedra testified that he did not arm himself with the weapon prior to the *409 attack but merely seized it from his assailants during the attack to prevent aggravation of his injuries, and that he did not immediately disclose the weapon to the correctional officers because of his injuries. This evidence was sufficient to warrant instruction on self-defense.
However, we find the failure to instruct on self-defense harmless even assuming the more stringent harmless beyond a reasonable doubt standard applies. (Chapman v. California (1967) 386 U.S. 18, 24, 87 S.Ct. 824, 17 L.Ed.2d 705; People v. Salas, supra, 37 Cal.4th at p. 984, 38 Cal.Rptr.3d 624, 127 P.3d 40 [standard of prejudice for failure to instruct on affirmative defense not yet defined]; see also People v. Demetrulias (2006) 39 Cal.4th 1, 23, 45 Cal.Rptr.3d 407, 137 P.3d 229.) Under the Chapman standard, an error is harmless if the record establishes beyond a reasonable doubt that the error did not contribute to the jury's guilty verdict. (People v. Flood (1998) 18 Cal.4th 470, 494, 76 Cal.Rptr.2d 180, 957 P.2d 869; People v. Lewis (2006) 139 Cal.App.4th 874, 889, 44 Cal.Rptr.3d 403.) "The question is whether there is a reasonable possibility that [the error] contributed to the conviction.'" (People v. Archer (2000) 82 Cal. App.4th 1380, 1394, 99 Cal.Rptr.2d 230.) "`To say that an error did not contribute to the verdict is ... to find that error unimportant in relation to everything else the jury considered on the issue in question, as revealed in the record.' [Citation]." (People v. Flood, supra, 18 Cal.4th at p. 494, 76 Cal.Rptr.2d 180, 957 P.2d 869.)
Here, because the jury was instructed on the necessity defense, it was apprised of a theory that would support acquittal had it believed Saavedra's testimony that he seized the weapon when one of his assailants dropped it and that after the fight he did not immediately disclose the weapon's existence because of his injuries.[3] We have no doubt that if the jury had believed Saavedra's testimony on these points, the jury would have found him not guilty of possession of a weapon based on the defense of necessity. A prison inmate who, while being severely beaten, manages to seize and secrete a weapon from an assailant and who discloses its existence to the authorities as soon as possible, has certainly sought to avoid a harm greater than the harm sought to be prevented by the prohibition on inmate weapon possession. Indeed, in closing argument to the jury, the prosecutor did not suggest that the necessity defense should not apply even if Saavedra's claims were believed, but rather urged the jury to convict based on an assessment that Saavedra was lying about his seizure of the weapon and/or about his inability to promptly disclose the weapon to the authorities.[4] We are satisfied the *410 jury's guilty verdict reflected that it was unconvinced that Saavedra was telling the truth about his acquisition and failure to disclose the weapon. It follows that the failure to instruct on self-defense did not affect the verdict because the jury did not find Saavedra's claims credible.
Saavedra argues the failure to instruct on self-defense was prejudicial because the prosecution has the burden to disprove self-defense beyond a reasonable doubt, whereas the defendant has the burden to prove the necessity defense by a preponderance of the evidence. We are not persuaded that the burden of proof should properly rest on the prosecution when self-defense is applied to the offense of possession of a weapon by an inmate.
As a matter of constitutional due process, the defendant need only raise a reasonable doubt regarding a defense that negates an element of the crime, and in this situation the burden of persuasion is on the People to show the nonexistence of the defense beyond a reasonable doubt. (People v. Tewksbury (1976) 15 Cal.3d 953, 963-964, 127 Cal.Rptr. 135, 544 P.2d 1335; People v. Adrian (1982) 135 Cal.App.3d 335, 340-342, 185 Cal.Rptr. 506; People v. Noble (2002) 100 Cal.App.4th 184, 189, 121 Cal.Rptr.2d 918; see also People v. Mower (2002) 28 Cal.4th 457, 479-480, 122 Cal. Rptr.2d 326, 49 P.3d 1067.) In contrast, when the defense does not directly concern an element of the crime but exonerates the defendant as a matter of public policy, there is no constitutional impediment to requiring the defendant to prove the defense by a preponderance of the evidence. (See People v. Tewksbury, supra, 15 Cal.3d at p. 964, 127 Cal.Rptr. 135, 544 P.2d 1335 [defendant must prove entrapment defense]; People v. Condley (1977) 69 Cal.App.3d 999, 1009-1013, 138 Cal. Rptr. 515 [defendant must prove necessity defense for offense of escape from prison].) Typically, the prosecution has the burden to prove a defendant did not act in self-defense, because self-defense negates an element of the offense. (See People v. Rios (2000) 23 Cal.4th 450, 461-62, 97 Cal.Rptr.2d 512, 2 P.3d 1066 [prosecution must disprove self-defense to prove malice for murder]; People v. Adrian, supra, 135 Cal.App.3d at pp. 340-341, 185 Cal.Rptr. 506 [prosecution must disprove self-defense to prove unlawful use of force for assault]; People v. Lee (2005) 131 Cal. App.4th 1413, 1422-1423, & fn. 2, 32 Cal. Rptr.3d 745 [prosecution must disprove self-defense to prove grossly negligent discharge of firearm].)
To show a violation of section 4502 the prosecution must prove that the defendant knew the prohibited object was in his or her possession, but need not prove the intent or purpose for which the weapon was possessed. (People v. Reynolds (1988) 205 Cal.App.3d 776, 779, 252 Cal.Rptr. 637, overruled on other grounds in People v. Flood, supra, 18 Cal.4th at pp. 484, 490, fn. 12, 76 Cal.Rptr.2d 180, 957 P.2d 869.) Section 4502 "`absolutely prohibits all prisoners in any state prison, without qualification, from possessing or carrying on their person certain designated deadly weapons. The intention with which the weapon is carried on the person is not made an element of the offense. Proof of the possession of the prohibited weapon infers that it is carried in violation of the statute.'" (People v. Purta, supra, 259 Cal. App.2d at p. 73, 66 Cal.Rptr. 38, italics added.) Thus, to establish the section 4502 offense, the prosecution need not prove that the inmate carried the weapon for an unlawful purpose. Unlike such offenses as murder, assault, and firearm discharge which require (respectively) proof *411 of malice, unlawful use of force, and gross negligence, the section 4502 offense does not contain an element that is negated by self-defense. Because self-defense for inmate weapon possession is not a defense related to the elements of the offense, the burden of proof may properly be placed on the defendant. Notably, this conclusion is consistent with section 12021, subdivision (h)(3), which places the burden on the defendant to prove by a preponderance of the evidence the statutory defense available to a convicted felon who seizes a weapon from a person committing a crime against the felon.
In any event, even assuming that the prosecution had the burden to disprove self-defense in the context of the section 4502 offense, the record shows beyond a reasonable doubt that the different burden of proof applicable to the necessity defense did not contribute to the guilty verdict. The jury concluded that Saavedra did not prove his necessity defense by a preponderance of the evidence based on his claims that he seized the weapon during the attack and disclosed its existence as soon as he was able. We are satisfied the jury's rejection of his claims was not influenced by the fact that it evaluated the evidence under this preponderance standard rather than the higher standard placing the burden on the prosecution. It strains credulity that while Saavedra was being attacked by two assailants, he managed to observe the weapon fall to the ground, seize the weapon, and successfully place the weapon in his shoe without interference from his attackers. Additionally, he could not have prevailed on a self-defense or necessity claim unless he turned the weapon over to the authorities as soon as possible after the danger had ended. Even under his version of the facts, he did not disclose the weapon's existence until the officer started searching him. This circumstance creates a strong inference that any such disclosure was motivated by a recognition that the weapon would be discovered, not by a preexisting intent to disclose the weapon. On these facts, there is no reasonable possibility that the verdict was affected by the jury's evaluation of the defense claim based on whether the defendant proved it by a preponderance of the evidence rather than whether the prosecution disproved it beyond a reasonable doubt.

Ineffective Assistance of Counsel
To prevail on a claim of ineffective assistance of counsel the defendant must establish that defense counsel's performance fell below an objective standard of reasonableness, and there is a reasonable probability the defendant would have obtained a more favorable result absent counsel's shortcomings. (People v. Cunningham (2001) 25 Cal.4th 926, 1003, 108 Cal.Rptr.2d 291, 25 P.3d 519.) If the record does not show prejudice from the alleged incompetence, a reviewing court may reject the claim without determining whether counsel's performance was deficient. (People v. Kipp (1998) 18 Cal.4th 349, 366, 75 Cal.Rptr.2d 716, 956 P.2d 1169.)
For the reasons stated in our analysis above, Saavedra's claim of ineffective assistance of counsel fails. Counsel was not ineffective for failing to request a duress instruction because the evidence did not support this defense. Even if reasonably competent counsel would have requested a self-defense instruction, there was no prejudice from counsel's failure to do so.

DISPOSITION
The judgment is affirmed.
WE CONCUR: McCONNELL, P.J., and O'ROURKE, J.
NOTES
[1]  Subsequent statutory references are to the Penal Code.
[2]  In King, the California Supreme Court left open the question of whether self-defense should be available as a defense to inmate weapon possession. (People v. King, supra, 22 Cal.3d at p. 25, fn. 6, 148 Cal.Rptr. 409, 582 P.2d 1000.)
[3]  The jury was instructed that Saavedra was "not guilty of possession of a weapon in a penal institution if he acted because of legal necessity. In order to establish this defense, the defendant must prove that, one, he acted in an emergency to prevent a significant bodily harm or evil to himself; two, he had no adequate legal alternative; three, the defendant's acts did not create a greater danger than the one avoided; ... four, when the defendant acted, he actually believed that the act was necessary to prevent the threatened harm or evil; [five,] a reasonable person would also have believed that the act was necessary under the circumstances; and, six, the defendant did not substantially contribute to the emergency." (See Judicial Council of Cal.Crim. Jury Instns. (2007-2008) CALCRIM No. 3403.)
[4]  For example, the prosecutor argued: "[T]he case turns on whether or not you believe what [the defendant] had to say.... [¶] ... [¶][I]n order for you to believe that necessity was established, you have to believe the defendant's testimony. You have to believe that, one, what he said was true about what happened. I submit to you, you have every reason not to believe what he had to say."
