This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
It is unnecessarily ineffective. The source text is contained once in the String field "text", and second time parsed in the TokenHierarchy as a CharBuffer. Since a CharBuffer over a String doesn't need to copy the content, slight change in the data flow can ensure the data is shared and not duplicated. I'll attach a patch for review. I did a few cleanups old code and tried to keep the semantic strictly equivalent, but if you know the text can be cached in the Text field also in other cases (than ctor), you can simplify it more. Also, in case that synchronized sections around accessing the text field are there only for proper inter-thread communication, marking the field volatile instead would make the code more readable, as safe (even more - there's currently no sync in ctor) and not blocking at all.
Created attachment 49165 [details] Fix
Seems fine to me, feel free to commit it.
OK java/source/src/org/netbeans/modules/java/source/parsing/SourceFileObject.java,v1.19