Japan stayed ahead of China as the world's number two economy in 2009 but came close to losing the position it has held for more than 40 years, official data showed Monday. Japan posted nominal gross domestic product of about 5.1 trillion dollars last year, the government announced. China reported last month nominal GDP of about 4.9 trillion dollars for 2009. But with China expected to enjoy another year of strong growth in 2010, Japan risks ending this year in third place worldwide as it struggles to cope with renewed deflation and a shrinking population, analysts said. 