Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavaescape analysis scalar replacementSingle-choice MCQ

In this method, why might HotSpot's escape analysis FAIL to scalar-replace the Point object even though it looks local, and what concept describes the obstacle?

int distance() { Point p = new Point(3, 4); // looks non-escaping return compute(p); // if compute() is not inlined, p escapes as an arg } // where Point holds final int x, y; and compute reads p.x, p.y