
48 Cal.2d 141 (1957)
LEWIS AND QUEEN (a Partnership) et al., Appellants,
v.
N. M. BALL SONS (a Partnership) et al., Respondents.
S. F. No. 19563. 
Supreme Court of California. In Bank.  
Mar. 19, 1957.
 Howard B. Crittenden, Jr., for Appellants.
 Thelen, Marrin, Johnson & Bridges, Gordon Johnson and Dario De Benedictis for Respondents.
 TRAYNOR, J.
 Plaintiffs George W. Lewis and Paul C. Queen are engaged in the contracting business as the partnership of Lewis and Queen, hereinafter referred to as plaintiff. Defendant Ball Sons, hereinafter referred to as defendant, is also in the contracting business. *145
 In June, 1949, defendant was awarded two contracts by the state, each contract for the construction of a separate section of the Hollywood Parkway. Defendant then entered into four contracts with plaintiff. With respect to the work to be done on each section of the parkway, there were two contracts between plaintiff and defendant. The first was entitled a "subcontract," and under it plaintiff agreed to remove concrete encountered during excavation of the roadway and apply water needed in the process of compacting the ground. The second was entitled an "equipment rental agreement," and under it plaintiff agreed to provide defendant with construction equipment for road excavation, "overhaul," and compacting.
 Plaintiff brought this action for damages for breach of the equipment rental agreements and for the reasonable rental value of equipment alleged to have been held beyond the agreed rental term. Plaintiff also sought to recover against sureties on labor and material bonds posted by defendant in compliance with Government Code, section 4200, before commencing work on the parkway, and stop notice bonds posted by defendant pursuant to Code of Civil Procedure, section 1184e (now  1192.1) after the present dispute arose. Defendant answered denying that it had breached the rental agreements, and filed a cross-complaint in which it alleged a breach of the agreements by plaintiff and sought to recover overpayments made to plaintiff.
 The trial court found that before the execution of the rental agreements plaintiff and defendant had entered into an oral agreement that plaintiff would undertake as a single subcontract the removal of concrete, application of water, excavation, overhaul, and compacting of original ground. Defendant then discovered that if it subcontracted all of this work, it would violate provisions in its contracts with the state that required it to perform with its own organization work of a value of not less than fifty per cent of the value of all the work embraced in the state contracts. The parties agreed therefore, with the intention of circumventing the provisions in the state contracts, to divide the five items of work under each state contract between two writings, a subcontract and an equipment rental agreement. Notwithstanding the form of these writings, it remained the agreement of the parties that plaintiff would perform all five items of work as an integrated subcontract operation. *146
 There was substantial evidence to support these findings. The rental agreements themselves provided for compensation based on the number of cubic yards of earth moved or square yards compacted rather than on the period of time during which defendant had use of the equipment, and the rental term was the time required to do the work called for by the state contracts. Testimony indicated that plaintiff furnished and retained control over both operating and supervisory employees, that it moved equipment to and from other jobs without defendant's consent, and that it carried on the work under both subcontracts and rental agreements with the same personnel, equipment, and accounting. Defendant paid wages, payroll taxes, and compensation insurance for employees operating the machines, but these costs were charged against amounts owing plaintiff under the rental agreements and so ultimately were borne by it. Monthly progress reports from defendant to plaintiff were on single form and made no segregation between charges attributable to work under the rental agreements and charges attributable to work under the subcontracts. The evidence, especially the testimony of Stanley Ball, tended to show that for all practical purposes the work was conducted by plaintiff, and that defendant exercised only such control as was necessary to coordinate the various subcontractors working on the parkway.
 The trial court concluded that plaintiff had agreed to act and had in fact acted as a contractor within the meaning of section 7026 of the Business and Professions Code, and that because it had done so without the license required by section 7028, it was barred by section 7031 from maintaining any action for compensation. Lewis had an individual license, but neither Queen nor the partnership of Lewis and Queen had licenses. The court held, in the alternative, that the rental agreements were unenforceable because they violated the provisions in the state contracts against subcontracting more than a certain amount of the total work. Since we have concluded that plaintiff's failure to obtain a license prevented it from maintaining any action for compensation, we have no cause to consider this alternative ground. The court entered judgment for defendant on the complaint and for plaintiff on the cross-complaint. Plaintiff appeals from the judgment against it.  [fn. *]*147
 Section 7028 of the Business and Professions Code makes it unlawful for "any person to engage in the business or act in the capacity of a contractor within this State without having a license therefor. ..." Section 7026 defines a contractor as "any person, who ... does himself or by or through others, construct, alter, repair, add to, subtract from, improve, move, wreck or demolish any building, highway, road ... or improvement. ..." "The term contractor includes subcontractor. ..." Section 7030 makes it a misdemeanor for any person to act in the capacity of a contractor without a license. Section 7031 provides that, "No person engaged in the business or acting in the capacity of a contractor, may bring or maintain any action in any court of this State for the collection of compensation for the performance of any act or contract for which a license is required by this chapter without alleging and proving that he was a duly licensed contractor at all times during the performance of such act or contract."
 Furthermore, section 7025 states that the "person" required to have a license by section 7028 includes a partnership, and section 7029 makes it unlawful for two individuals, "each of whom has been issued a license to engage separately in the business ... of a contractor ... to jointly ... act in the capacity of a contractor ... without first having secured an additional license for acting in the capacity of such a joint venture or combination. ..."
 [1] The evidence shows that in spite of the form of the rental agreements plaintiff actually undertook to and did in fact "construct a highway" for defendant, and thereby acted as a contractor within the meaning of section 7026. (See Albaugh v. Moss Constr. Co., 125 Cal.App.2d 126, 132-133 [269 P.2d 936]; Phillips v. McIntosh, 51 Cal.App.2d 340, 343 [124 P.2d 835]; cf. Harrison v. Shamalian, 110 Cal.App.2d 500 [243 P.2d 82]; Andrew v. Conner, 101 Cal.App.2d 621 [225 P.2d 943].)
 Plaintiff contends, however, that because defendant admitted in its answer that equipment had been furnished under the written rental agreements, the trial court was precluded from finding that the actual agreements were subcontracts because it should have restricted its findings to the issues made by the pleadings. There is no merit in this contention. [2] Whatever the state of the pleadings, when the evidence shows that the plaintiff in substance seeks to enforce an illegal contract or recover compensation for an illegal act, the court *148 has both the power and duty to ascertain the true facts in order that it may not unwittingly lend its assistance to the consummation or encouragement of what public policy forbids. (Wells v. Comstock, 46 Cal.2d 528, 532 [297 P.2d 961]; Franklin v. Nat C. Goldstone Agency, 33 Cal.2d 628, 629 [204 P.2d 37]; Fewel & Dawes, Inc. v. Pratt, 17 Cal.2d 85, 92 [109 P.2d 650]; Endicott v. Rosenthal, 216 Cal. 721, 728 [16 P.2d 673]; Tevis v. Blanchard, 122 Cal.App.2d 731, 732-734 [266 P.2d 85]; see Owens v. Haslett, 98 Cal.App.2d 829, 835-836 [221 P.2d 252].) [3] It is immaterial that the parties, whether by inadvertence or consent, even at the trial do not raise the issue. The court may do so of its own motion when the testimony produces evidence of illegality. (Norwood v. Judd, 93 Cal.App.2d 276, 277-278, 282 [209 P.2d 24].) It is not too late to raise the issue on motion for new trial (Pacific Wharf & Storage Co. v. Standard American Dredging Co., 184 Cal. 21, 23-24 [192 P. 847]), in a proceeding to enforce an arbitration award (Franklin v. Nat C. Goldstone Agency, 33 Cal.2d 628, 629 [204 P.2d 37]), or even on appeal. (Morey v. Paladini, 187 Cal. 727, 733-734 [203 P. 760].) In the present case the issue was in fact raised during the trial.
 Equally without merit is plaintiff's contention that because the rental agreements stated that they contained all provisions agreed to by the parties, the parol evidence rule precluded the admission of other evidence showing the true nature of the agreement between the parties and that plaintiff had in fact acted as a contractor. [4] The parol evidence rule does not exclude evidence showing that a contract lawful on its face is in fact part of an illegal transaction. (Code Civ. Proc.,  1856; Endicott v. Rosenthal, 216 Cal. 721, 728 [16 P.2d 673]; May v. Herron, 127 Cal.App.2d 707, 710-711 [274 P.2d 484]; Kennerson v. Salih Brothers, 123 Cal.App.2d 371, 374 [266 P.2d 871]; De Armas v. Dickerman, 108 Cal.App.2d 548, 551-552 [239 P.2d 65].) [5] The policy in favor of narrowing the issues in dispute, which normally confines the court to those made by the pleadings, and the policy of the parol evidence rule favoring the conclusiveness of integrated written agreements, both give way before the importance of discouraging illegal conduct. To this end, the trial court must be free to search out illegality lying behind the forms in which the parties have cast the transaction to conceal such illegality.
 [6] Plaintiff contends that even if it acted as a contractor *149 under section 7026, it substantially complied with the requirement of section 7028, since Lewis held an individual license. The "person" that did the contracting work, and was required by section 7028 to have a license, however, was the partnership of Lewis and Queen, and it had no license. Nor did Queen individually. [7] Section 7029, furthermore, expressly requires individual licensees who engage jointly in the contracting business to obtain an additional, joint license. (Cf. Joseph v. Drew, 36 Cal.2d 575, 578 [225 P.2d 504]; Wise v. Radis, 74 Cal.App. 765, 773 [242 P. 90].)
 Undoubtedly there are situations in which substantial compliance with the licensing requirements satisfies the policy of the statute. (See Gatti v. Highland Park Builders, Inc., 27 Cal.2d 687, 689-691 [166 P.2d 265]; Citizens State Bank of Long Beach v. Gentry, 20 Cal.App.2d 415, 419-420 [67 P.2d 364]; cf. Oddo v. Hedde, 101 Cal.App.2d 375 [225 P.2d 929].) The facts of the present case, however, with one partner licensed individually and no partnership license, are precisely those in Loving & Evans v. Blick, 33 Cal.2d 603 [204 P.2d 23], and in that case we said, "There can be no question but that this case presents a clear violation of the statutes regulating the contracting business." (33 Cal.2d at 607; see also Kirman v. Borzage, 65 Cal.App.2d 156, 158-159 [150 P.2d 3]; Holm v. Bramwell, 20 Cal.App.2d 332, 335-336 [67 P.2d 114].) We distinguished Gatti v. Highland Park Builders, Inc., supra, on the ground that there both partners held individual licenses and during the performance of the contract a joint license was issued to them and a third person, and Citizens State Bank of Long Beach v. Gentry, supra, on the ground that in that case, although the plaintiff's license expired while the work was in progress, it was renewed in the name of a corporation controlled by him.
 In both the Gatti and Gentry cases, any matter that might have formed the subject of inquiry by the licensing board in determining whether to issue an additional license was necessarily considered in connection with the licenses actually issued. In the present case, however, the board has never determined the qualifications of Queen. [8] Plaintiff claims that this makes no difference, because it was Lewis who supervised the actual construction work and Queen merely kept the books and sought out new business for the partnership. But the statutory provisions setting forth the qualifications for a license, and the causes for disciplinary action against licensees, show that the Legislature was as much concerned *150 to protect the public from dishonesty and incompetence in the administration of the contracting business as in the actual use of bricks, mortar, and earth- moving equipment. (E.g.,  7068, 7069, 7120.) Plaintiff's insistence that Queen knew nothing about actual construction simply emphasizes the importance of the board's passing on his qualifications to engage in any aspect of the contracting business. The statute makes it clear, furthermore, that if the contractor is a partnership, the experience, knowledge, and integrity of each partner is a vital consideration in determining whether to issue a license. (E.g.,  7067, 7069, 7071.) Finally, it is not clear that Queen's activities were in fact confined to bookkeeping and the search for new business. He participated with Lewis in the negotiations that led to the execution of the contracts, and he "walked the job," apparently to determine what problems would be encountered if the work was undertaken. The conclusion is inescapable that plaintiff did not substantially comply with the licensing requirements.
 [9] Since plaintiff did not comply with the statute, it cannot "bring or maintain any action in any court of this State for the collection of compensation. ..." ( 7031; Loving & Evans v. Blick, 33 Cal.2d 603 [204 P.2d 23].) [10] Plaintiff contends, nevertheless, that because defendant has been paid in full by the state for all work done on the parkway, justice requires that it be compelled to turn over to plaintiff the proceeds from the state contracts attributable to plaintiff's labor.
 One answer to this contention is that, even in the absence of a provision such as section 7031, the courts generally will not enforce an illegal bargain or lend their assistance to a party who seeks compensation for an illegal act. The reason for this refusal is not that the courts are unaware of possible injustice between the parties, and that the defendant may be left in possession of some benefit he should in good conscience turn over to the plaintiff, but that this consideration is outweighed by the importance of deterring illegal conduct. Knowing that they will receive no help from the courts and must trust completely to each other's good faith, the parties are less likely to enter an illegal arrangement in the first place. (See Takeuchi v. Schmuck, 206 Cal. 782, 786-787 [276 P. 345]; May v. Herron, 127 Cal.App.2d 707, 712 [274 P.2d 484]; Orlinoff v. Campbell, 91 Cal.App.2d 382, 388 [205 P.2d 67]; Wise v. Radis, 74 Cal.App. 765, 778 *151 [242 P. 90]; Grodecki, In Pari Delicto Potior Est Conditio Defendentis, 71 L.Q.Rev. 254, 266-268.)
 In some cases, on the other hand, the statute making the conduct illegal, in providing for a fine or administrative discipline excludes by implication the additional penalty involved in holding the illegal contract unenforceable; or effective deterrence is best realized by enforcing the plaintiff's claim rather than leaving the defendant in possession of the benefit; or the forfeiture resulting from unenforceability is disproportionately harsh considering the nature of the illegality. In each such case, how the aims of policy can best be achieved depends on the kind of illegality and the particular facts involved. (See Wilson v. Stearns, 123 Cal.App.2d 472, 481-482 [267 P.2d 59]; John E. Rosasco Creameries, Inc. v. Cohen, 276 N.Y. 274, 278-280 [11 N.E.2d 908, 118 A.L.R. 641]; 6 Corbin, Contracts 964-967 (1951); 2 Pomeroy, Equity Jurisprudence 137 (5th ed. 1941); Grodecki, In Pari Delicto Potior Est Conditio Defendentis, 71 L.Q.Rev. 254, 268.) But we are not free to weigh these considerations in the present case. [11] Section 7031 represents a legislative determination that the importance of deterring unlicensed persons from engaging in the contracting business outweighs any harshness between the parties, and that such deterrence can best be realized by denying violators the right to maintain any action for compensation in the courts of the state (Kirman v. Borzage, 65 Cal.App.2d 156, 158 [150 P.2d 3].) Moreover, even if we could take into account unjust enrichment of defendant, it is not at all clear that, had it reached the issue, the trial court would have found defendant indebted to plaintiff beyond what it had already paid.
 Norwood v. Judd, 93 Cal.App.2d 276 [209 P.2d 24], Galich v. Brkich, 103 Cal.App.2d 187 [229 P.2d 89], and Wold v. Luigi Consentino & Sons, 109 Cal.App.2d 854 [241 P.2d 1032], do not support plaintiff's right to recover. Each of those cases involved an action by a partner or joint venturer to recover a share of profits arising from an illegal enterprise. It was held that, since the enterprise was terminated, since it was not illegal as such but only for want of a license, and since the action was not against a third person for whose protection the statute had been primarily enacted but against a partner or joint venturer, the purpose of the law would not be served by denying relief. We need not decide at this time whether an action for an accounting against a partner or joint venturer is "an action for the collection of *152 compensation" within section 7031 (cf. Wise v. Radis, 74 Cal.App. 765, 775 [242 P. 90]) or, even if it is not, whether the indirect encouragement of an illegal enterprise resulting from the allowance of such an action is sufficient to outweigh the evil of unjust enrichment. (See Hooper v. Barranti, 81 Cal.App.2d 570, 575-578 [184 P.2d 688]; 32 A.L.R.2d 1345, 1387; Wade, Restitution of Benefits Acquired Through Illegal Transactions, 95 U.Pa.L.Rev. 261, 294-296; but see Denning v. Taber, 70 Cal.App.2d 253, 257-260 [160 P.2d 900].) [12] The present action is against a third party, and is to enforce directly an illegal contract, not merely to obtain an accounting for profits arising from one. As Norwood v. Judd itself recognizes, this situation falls squarely within section 7031. (93 Cal.App.2d 276, 283.)
 Plaintiff next contends that, by virtue of the fact that it is a subcontractor suing a general contractor rather than a general contractor suing an owner, neither section 7031 nor the general rule that illegal contracts are unenforceable bars its action. Matchett v. Gould, 131 Cal.App.2d 821 [281 P.2d 524], appears to make this distinction decisive. In that case the Crane Service Company and the defendants, all unlicensed contractors, decided to undertake the demolition of buildings for a school district. The understanding between Crane and the defendants was that Crane would make the bid and defendants supply the funds to pay the school district; that the defendants would then do the actual work of taking down the bricks, using for this purpose Crane's machines, for which a reasonable rental would be paid; the defendants would pay Crane for removing concrete and rough-grading the site, and all salvageable material would belong to the defendants. After the job was completed and the defendants had received all the revenues from the sale of salvage, they refused to pay Crane. Crane's assignee sued to enforce the contract.
 The District Court of Appeal held that the plaintiff could recover in spite of section 7031. The first ground of its decision appears to be that, unless the plaintiff was allowed to recover the defendants would be unjustly enriched. [13] As we have already pointed out, the courts may not resort to equitable considerations in defiance of section 7031. As an alternative ground, the court reasoned that Crane had in effect assigned the school district contract to defendants and then become their subcontractor; that subcontractors are in a class for whose protection the licensing statute was enacted (relying on our statement in Fraenkel v. Bank of *153 America, 40 Cal.2d 845, 848 [256 P.2d 569], that the statute was designed "for the prevention of fraudulent acts by contractors resulting in loss to subcontractors, materialmen, employees, and owners of structures"); and that therefore a subcontractor can maintain an action on a contract with a general contractor, even though it is an illegal contract, because the subcontractor is not considered in pari delicto. (131 Cal.App.2d at 829.)
 [14] It is true that when the Legislature enacts a statute forbidding certain conduct for the purpose of protecting one class of persons from the activities of another, a member of the protected class may maintain an action notwithstanding the fact that he has shared in the illegal transaction. The protective purpose of the legislation is realized by allowing the plaintiff to maintain his action against a defendant within the class primarily to be deterred. In this situation it is said that the plaintiff is not in pari delicto. (Carter v. Seabord Finance Co., 33 Cal.2d 564, 574 [203 P.2d 758]; McAllister v. Drapeau, 14 Cal.2d 102, 112 [92 P.2d 911, 125 A.L.R. 800]; Pollak v. Staunton, 210 Cal. 656, 662-663 [293 P. 26]; Elmers v. Shapiro, 91 Cal.App.2d 741, 754 [205 P.2d 1052]; see Grodecki, In Pari Delicto Potior Est Conditio Defendentis, 71 L.Q.Rev. 254, 265; Wade, Restitution of Benefits Acquired Through Illegal Transactions, 95 U.Pa.L.Rev. 261, 268-270.)
 [15] But subcontractors are not always in the class to be protected simply because they are subcontractors, and we did not suggest otherwise in Fraenkel v. Bank of America, 40 Cal.2d 845, 848 [256 P.2d 569]. (See Albaugh v. Moss Constr. Co., 125 Cal.App.2d 126, 132 [269 P.2d 936]; Holm v. Bramwell, 20 Cal.App.2d 332 [67 P.2d 114].) The class protected by the statute includes those who deal with a person required by the statute to have a license. [16] When the person required to have a license is a general contractor, then the protected class includes subcontractors, materialmen, employees, and owners dealing with the general contractor. [17] However, when the person who was required to have a license but did not have one is himself a subcontractor, such as plaintiff in the present case, he of course is not to be protected from his own unlicensed activities. To allow him to recover would in fact destroy the protection of those who dealt with him, and they are in the class the Legislature intended to protect whether they are owners or general contractors. (Cf. Hedlund v. Sutter Medical Service Co., 51 Cal.App.2d 327, 333 [124 P.2d 878]; 2 Pomeroy, Equity Jurisprudence *154 142 (5th ed. 1941).) To the extent that it is contrary, the reasoning of Matchett v. Gould, 131 Cal.App.2d 821 [281 P.2d 524], is erroneous and is disapproved. Under the facts of the present case plaintiff is not in the class to be protected, and therefore is not relieved from the imputation of being in pari delicto. Its failure to obtain a license, and not any fault of defendant in this regard, made the transaction illegal.
 [18] There is no merit in plaintiff's further contention that it may maintain this action simply because it is an action against a licensed member of plaintiff's own profession, rather than against the owner for whose ultimate benefit the work was done. General contractors as much as owners are entitled to raise the defense of lack of a license in the subcontractor. If they were not, section 7031 would be no deterrent to subcontractors, since they generally do look to the general contractor for compensation. Yet section 7026, stating that "the term contractor includes subcontractor," clearly imposes on unlicensed subcontractors the same disabilities as on unlicensed general contractors. Cases from other jurisdictions cited by plaintiff (e.g., Dow v. United States, for Use and Benefit of Holley, 154 F.2d 707, 710 [10th Cir.]), do not involve statutory prohibitions like section 7031.
 [19a] Plaintiff's final contention is that, even if it cannot recover on the rental agreements from defendant, the defense of lack of a license is not available to the sureties on the bonds. Section 7031 provides, however, that no person who acts as a contractor "may bring or maintain any action ... for the collection of compensation for the performance of any act ..." for which a license is required, without alleging and proving that he was licensed. (Italics added.) [20] We have already held that an action to enforce an arbitration award is an action within the meaning of this provision (Loving & Evans v. Blick, 33 Cal.2d 603, 613 [204 P.2d 23]; Franklin v. Nat C. Goldstone Agency, 33 Cal.2d 628, 631-633 [204 P.2d 37]), and it is clear that an action to foreclose a mechanic's lien is also. (Albaugh v. Moss Constr. Co., 125 Cal.App.2d 126, 132 [269 P.2d 936]; Cash v. Blackett, 87 Cal.App.2d 233, 237 [196 P.2d 585]; Siemens v. Meconi, 44 Cal.App.2d 641 [112 P.2d 904]; Holm v. Bramwell, 20 Cal.App.2d 332, 334 [67 P.2d 114].) [19b] In view of the purpose of section 7031, we can see no reason to distinguish an action on a bond. In all of these cases the object of the plaintiff is to obtain, more or less directly, compensation for unlicensed work. The deterrent purpose behind section 7031 would be frustrated if the *155 plaintiff, prevented from obtaining compensation directly by an action on his contract, could obtain it indirectly by an action on a bond.
 [21] Moreover, even in the absence of section 7031, the defense of illegality is available to the surety if it is available to his principal. (Wells v. Comstock, 46 Cal.2d 528, 533 [297 P.2d 961]; Rest., Security,  117, comment d.) Lewis & Queen v. S. Edmondson & Sons, 113 Cal.App.2d 705, 707-708 [248 P.2d 973], and Pneucrete Corp. v. United States Fid. & Guar. Co., 7 Cal.App.2d 733, 736-740 [46 P.2d 1000], which are cited by plaintiff, in spite of broad language in the opinions do not hold otherwise. The obligation of the sureties on defendant's bonds was not to pay for labor merely by virtue of the fact that it had been expended on the parkway. It was an obligation to pay only if plaintiff established, without reference to the bond, a legal and valid claim for compensation. (See Civ. Code,  2810; Flickinger v. Swedlow Engineering Co., 45 Cal.2d 388, 393-394 [289 P.2d 214]; Rest., Security  117, comment c.) This plaintiff has not done.
 Appeal from order denying motion for new trial dismissed. Judgment affirmed.
 Shenk, J., Spence, J., and McComb, J., concurred.
 CARTER, J.
 I dissent.
 In my opinion, the strict construction placed upon Business and Professions Code sections, particularly section 7031, by the majority is unwarranted. Section 7031 is but a statutory declaration of the common law rule that a contract which violates a statute designated for the protection of the public is void and unenforceable. (Levinson v. Boas, 150 Cal. 185 [88 P. 825, 11 Ann.Cas. 661, 12 L.R.A.N.S. 575]; Berka v. Woodward, 125 Cal. 119 [57 P. 777, 73 Am.St.Rep. 31, 45 L.R.A. 420]; 12 Am.Jur., Contracts,  158, p. 652.) This rule, however, is not applied where to do so does not serve the intended purpose of the statute. (Wilson v. Stearns, 123 Cal.App.2d 472, 478 [267 P.2d 59], citing Harris v. Runnels, 12 How. (U.S.) 79 [13 L.Ed. 901]; 12 Am.Jur., Contracts,  162, p. 657.) At one time in this state, statutes, such as section 7031, which expressly deny the enforcement of contracts which violate a particular law, were strictly construed to prevent recovery. (See e.g., Wise v. Radis, 74 Cal.App. 765 [242 P. 90], involving a statute which prevented the enforcement of certain contracts by unlicensed real estate *156 brokers.) More recently, however, section 7031, although literally applicable, has not been applied where enforcement of the contract was considered not to be adverse to the public interest sought to be protected by the pertinent Business and Professions Code sections. (Gatti v. Highland Park Builders, Inc., 27 Cal.2d 687 [166 P.2d 265]; Citizens State Bank v. Gentry, 20 Cal.App.2d 415 [67 P.2d 364]; Norwood v. Judd, 93 Cal.App.2d 276 [209 P.2d 24]; Galich v. Brkich, 103 Cal.App.2d 187 [229 P.2d 89]; Wold v. Luigi Consentino & Sons, 109 Cal.App.2d 854 [241 P.2d 1032]; Matchett v. Gould, 131 Cal.App.2d 821 [281 P.2d 524].) The effect of these cases is that the common law exceptions to the rule are recognized as being preferable to a strict, literal construction of the statutory language. Accordingly, the conclusion of the majority--that because plaintiff is within the statutory definition (subcontractor) and seeks recovery of his share of the proceeds arising from the work, it necessarily follows that recovery must be denied--is based upon an incomplete analysis of the question presented. Rather, an examination should be made to determine whether the intended statutory purpose requires the denial of enforcement of this particular contract. Such an examination, it is submitted, demonstrates that the statute was not so intended.
 The facts of this case are quite similar to those in Norwood v. Judd, supra. There, plaintiff and defendant had formed a partnership to conduct a contracting business. Defendant was a duly licensed contractor but neither plaintiff nor the partnership was. Plaintiff brought an action to recover his share of the business proceeds from his partner. Literally, Business and Professions Code, section 7031, would have barred plaintiff's action as it provides, in part, that: "No person engaged in the business or acting in the capacity of a contractor, may bring or maintain any action ... for the collection of compensation for the performance of any act or contract for which a license is required by this chapter without alleging and proving that he was a duly licensed contractor at all times during the performance of such act or contract." However, recovery was allowed and the court declared (93 Cal.App.2d at 286) that "It must be remembered that these licensing statutes are passed primarily for the protection and safety of the public. They are not passed for the benefit of a greedy partner who seeks to keep for himself all of the fruits of the partnership enterprise to the exclusion of another partner entitled to share therein. Where the illegal transaction has been terminated, public policy is not protected *157 or served by denying one partner relief against the other." It was further noted (p. 288) that Wise v. Radis, supra, (applying the strict rule of construction) had been overruled in legal effect. Defendant's petition for a hearing in the Norwood case was denied by this court.
 A similar problem was presented in Galich v. Brkich, supra, 103 Cal.App.2d 187. Plaintiff, apparently an unlicensed contractor, entered into a joint venture or partnership agreement with defendant. No license was obtained for the enterprise as required by Business and Professions Code, section 7029. In allowing recovery by plaintiff of the money due him for the contracting work performed by the venture, the court declared (p. 191) that "The contract in question was not per se contrary to any statute; public welfare and safety were not threatened, and public policy would not be protected or served by denying one partner relief against the other." Applying the reasoning of the Norwood case, supra, the court observed that "... the rule that courts will not lend their aid to the enforcement of an illegal agreement should not be 'blindly' extended to 'every case where illegality appears somewhere in the transaction.' " Defendant's petition for a hearing in this court was denied.
 In Wold v. Luigi Consentino & Sons, supra, 109 Cal.App.2d 854, the same problem was again presented. The application of the statute was rejected, the court declaring (p. 857) that its main purpose was protection of owners.
 Recovery was allowed in these cases because the actions were not against those whom the statute was intended to protect, that is, an owner or other member of the general public who is without knowledge of or experience in contracting affairs, and hence, is wholly dependent upon the competence of the contractor. Accordingly, the statute was not applied to allow an associate of an unlicensed individual to retain the proceeds rightfully owing to the latter. It seems clear that this principle is applicable here, despite the absence of a partnership or joint venture relationship, for in practical effect, the circumstances are identical. Two parties agreed to perform work for a third party and one of the two has withheld the other's share of the proceeds. Upon facts identical to those in the present case, the Second District Court of Appeal in Matchett v. Gould, supra, 131 Cal.App.2d 821, applied the principle of the partnership cases and allowed recovery. In that case, neither plaintiff, a subcontractor, nor defendant, a general contractor, was licensed. Upon completion *158 of a contracting job for a third party, plaintiff sought the amount owing to him for the work performed. Analogizing to Norwood v. Judd, supra, the court allowed recovery and declared that the precise relationship between the parties, that is, whether partners or contractor and subcontractor, was not determinative and that the statute was not intended to prevent recovery where the unlicensed contractor has completed the job, where there is no serious moral turpitude involved and where a denial of recovery would permit unjust enrichment of one not intended to be protected, namely, the general contractor. Citing Gatti v. Highland Park Builders, Inc., supra, 27 Cal.2d 687, the court observed (131 Cal.App.2d at 829) that the statute was not intended as an "unwarranted shield for the avoidance of a just obligation."
 Here, the majority, to sustain their decision that plaintiff is precluded from enforcing his contract, concludes that the reasoning of Matchett v. Gould, supra, is erroneous, although a petition for hearing in that case was denied by this court. The majority opinion further declares that "To allow him [plaintiff] to recover would in fact destroy the protection of those who dealt with him, and they are in the class the Legislature intended to protect whether they are owners or general contractors." What protection is to be afforded a general contractor? He is not in the position of a member of the public who desires contracting work performed and because of the disparity of knowledge and experience is extended statutory protection. Rather, his position is equal to that of the subcontractor and he is, therefore, able to judge the nature and quality of the subcontractor's performance for himself. If the statute was intended to "protect" a general contractor as a member of the public, as undeniably he is, then it should be applied to "protect," from one another, members of a partnership which has illegally undertaken contracting work. It has been seen, however, that the statute is not construed in such a fashion. In the interests of just and consistent application, it should not be so construed here. For this reason, I would reverse the judgment and remand the case for a determination of the cause on its merits.
 Schauer, J., concurred.
NOTES
[fn. *]  *. It also purports to appeal from an order denying a new trial. Such an order is not appealable, but may be reviewed on an appeal from a judgment. (Code Civ. Proc.,  956.)
