“the law.” This use of “law” is the general use of the word that refers to the whole Old Testament, not just the Torah, or Mosaic Law (Genesis-Deuteronomy). We know this because not one of the quotations in the earlier verses is from the Torah, they are all from the Psalms, writings, and prophetic books.
“the whole world.” It is fair to ask how, since “the law” was given to Israel, the “whole world” becomes guilty because of what “the law” says. Although the law was spoken in general to Israel, and there are certainly things in it that refer only to Israel, there is much of the “Old Testament” that applies to, or even was written to, the Gentiles. Considering that “the law” in the verse refers to the entire Old Testament, and not just the Torah, we can see that what is said in the verses quoted is true of both Jews and Gentiles.