Here [Romans 3.27] Paul says that while the “law of works” cannot eliminate boasting, the “law of faith” can and does. He then says in 8:1-2,
“There is therefore now no condemnation for those who are in Christ Jesus. For the law of the Spirit of life has set you free in Christ Jesus from the law of sin and death.”
Again,  law is pitted against law. Paul says that the believer is not under  condemnation because the “law of the Spirit of life” has set him free  from the “law of sin and death.” James uses different categories but  seems to have a similar distinction in mind:
“The one who looks into the perfect law, the law of liberty, and perseveres, being no hearer who forgets but a doer who acts, he will be blessed in his doing…. If you really fulfill the royal law according to the Scripture, “You shall love your neighbor as yourself,”  you are doing well. But if you show partiality, you are committing sin  and are convicted by the law as transgressors. For whoever keeps the whole law but fails in one point has become accountable for all of it. For he who  said, “Do not commit adultery,” also said, “Do not murder.” If you do  not commit adultery but do murder, you have become a transgressor of the  law. So speak and so act as those who are to be judged under the law of liberty” (1:25; 2:8-12).
Like  Paul, James here describes two laws with two distinct functions. One he  calls “the perfect law,” “the law of liberty,” and “the royal law.” The  other he refers to as “the whole law” or simply “the law.” Of this  latter James insists that even the slightest breach of its commands  constitutes a breaking of all, and that the believer’s failure to love  his neighbor renders him susceptible to this law, a law which will show  him no mercy on the day of judgment.
Concerning the “royal law”  and “law of liberty,” James teaches that this law is fulfilled by loving  our neighbor, and it is this that he considers being a “doer of the  Word, not a hearer only” (1:22). By fulfilling the royal law, he says,  we “do well,” and moreover, demonstrating mercy and love of neighbor is  what ensures that we will not be judged according to the strictness of  “the whole law,” but rather will be judged under the law of liberty.
source
I’ll add a few other data points.
In the midst of his argument that Faith without works is dead, James makes the statement, “You believe that God is one; you do well” (2.19a). If we see in this statement a reference to the Shema, Israel’s confession of monotheism, then James is not too far from Paul’s claim: “For circumcision indeed is of value if you obey the law, but if you break the law, your circumcision becomes uncircumcision” (Romans 2.25). And like James, Paul also contrasts mere hearers to doers: “For it is not the hearers of the law who are righteous before God, but the doers of the law who will be justified” (Romans 2.13). And Paul too, like James believes that love fulfills the law:
Owe no one anything, except to love each other, for the one who loves another has fulfilled the law. For  the commandments, “You shall not commit adultery, You shall not murder,  You shall not steal, You shall not covet,” and any other commandment,  are summed up in this word: “You shall love your neighbor as yourself.”  Love does no wrong to a neighbor; therefore love is the fulfilling of the law (Romans 13.8-10).
One other consideration that strikes me as relevant is James’ term “the royal law,” which seems to be a reference to Jesus the Messiah’s rule of life. This reminds me of what Paul says in Galatians 6.2: “Bear one another’s burdens, and so fulfill the law of Christ.” In the context, I think the “burdens” are mainly the ill effects of the sins of others that you suffer because you are one with them as Christians.
What I don’t see in James is a contrast between two laws. The “whole law” is identical to “the royal law” and the “perfect law,” the “law of liberty.” It is all one. Nor does James say that “the whole law” is extra strict and that the “slightest breach” of its commands results in condemnation. Rather, what he says is that if you choose to live as a double-minded hypocrite and only follow some commands while claiming to be exempt from others, you will be condemned.
Here is James 2.1-13:
My brothers, show no partiality as you hold the  faith in our Lord Jesus Christ, the Lord of glory. For if a man wearing a  gold ring and fine clothing comes into your assembly, and a poor man in  shabby clothing also comes in, and if you pay attention to the one who  wears the fine clothing and say, “You sit here in a good place,” while  you say to the poor man, “You stand over there,” or, “Sit down at my  feet,” have you not then made distinctions among yourselves and become  judges with evil thoughts? Listen, my beloved brothers, has not God  chosen those who are poor in the world to be rich in faith and heirs of  the kingdom, which he has promised to those who love him? But you have  dishonored the poor man. Are not the rich the ones who oppress you, and  the ones who drag you into court? Are they not the ones who blaspheme  the honorable name by which you were called? If you really fulfill the royal law according to  the Scripture, “You shall love your neighbor as yourself,” you are  doing well. But if you show partiality, you are committing sin and are  convicted by the law as transgressors. For whoever keeps the whole law  but fails in one point has become accountable for all of it. For he who  said, “Do not commit adultery,” also said, “Do not murder.” If you do  not commit adultery but do murder, you have become a transgressor of the  law. So speak and so act as those who are to be judged under the law of  liberty. For judgment is without mercy to one who has shown no mercy.  Mercy triumphs over judgment.
We see here the issue is partiality throughout and the law does not shift. The failure to keep the law at one point is not a “slightest breach” that we commit and must be forgiven of every day (as we find in the Lord’s Prayer) but rather a policy of discrimination that violates the law of Christ and is perverse holding on our professed faith in Christ.