Suppose, two countries 'X' and 'Y' were part of a larger country 'A'. They got independence from A or just got separated, say, in 2001. Both are members of the UN.
X and Y have a disputed area between them called 'P' which is under Y's control.
Then, after 10 years, in 2011, X suddenly attacks Y in an effort to occupy P.
Is it illegal for X to wage an war on Y? Why or why not?