responseText is not just a String, it is a field of the request object. Referencing a field of an object prevents the object from being eligible for GC.
ETA: this is my understanding of GC, but I could be wrong. Especially with Strings, which get interned and confuse me regularly.
This is just wrong. That's not how objects work in java.
String is a string is a string. The object doesn't know that it's stored in some other object's field. It doesn't care about any of the places where it is stored. If that other object becomes unreachable, it will be (eventually) GC'd, losing its reference to the string ... and then the string will be GC'd, unless it's reachable from other places.
Lexically, request.responseText is an attribute of the request object, but the object in it is not an attribute or a field.
The object in it *could* have a backreference to the containing object (if there was a closure, for an overcomplicated example), but Strings don't (and can't) do that.
And interning just means that string literals (what you write in the source code) are stored only once and reused, right?
(also, java doesn't call it "fields", afaik - maybe in the reflection API?).
Also, I think your use of "strong reference" and "weak reference" is mistaken. Strong references only prevent object from being GC'd if it's reachable from stack. You seem to think they prevent if from being GC'd always. (which could be something like a "superstrong" reference - reference stored in a variable that never goes out of scope, like static attribute).
ETA: or maybe you are thinking in terms of C++, where request.responseText would be like ..
class Request {
...
public: char[] responseText;
...
};
Then you couldn't GC responseText without GC'ing the entire request (and it's not that it wouldn't be safe - GCing responseText by itself would be invalid, because it's not a complete chunk on the heap).
But you alsowouldn't be GC'ing anything, because doing GC in C++ is a pain. In any case.