The Treaty on European Union (TEU) (a.k.a Treaty of Maastricht a.k.a. Treaty of Lisbon) states that:
Any European State which respects the values referred to in Article 2 and is committed to promoting them may apply to become a member of the Union.
Without further clarification on what defines a "European State".
A legal briefing clarified that "the term 'European State' need not be interpreted in a strictly geographical sense" (emphasis mine):
The sole material condition laid down by Article O of the TEU is that the applicant must be a 'European State'. There is no unequivocal interpretation of that criterion. It can be read equally well in geographical, cultural or political terms.
In 1987 an application to become a Member of the Communities was received from Morocco. The application was rejected by the Council on the grounds that Morocco was not a European State. In the case of Turkey, Article 28 of the Association Agreement signed in 1963 incudes the option of Turkey's eventually acceding to the Communities. Turkey in fact lodged an application to accede on 14 April 1987. Historically, Turkey has formed part of the so-called 'European concert'. Although part of Turkey's territory is located geographically in Asia, Parliament, the Council and the Commission have confirmed Turkey's eligibility. This example shows that the term 'European State' need not be interpreted in a strictly geographical sense. It is at all events a criterion subject to political assessment.
Overseas territories are also mentioned in the TEU:
The Member States agree to associate with the Union the non-European countries
and territories which have special relations with Denmark, France, the
Netherlands and the United Kingdom. These countries and territories (hereinafter
called the ‘countries and territories’) are listed in Annex II.
So it's unlikely that China could join the European Union even if it meets all the requirements since Morocco's application was denied on account of not being in Europe.
That being said, it's not unthinkable for the European Parliament to allow countries outside of Europe to apply at some point in the future, although China specifically is not a very likely country to join due to lack of historical and cultural ties. Israel is sometimes named as a country that could – perhaps – one day apply for EU membership.