开发者

How is Java's String#intern() method implemented?

开发者 https://www.devze.com 2023-01-08 10:40 出处:网络
I tried to look at Java\'s String#int开发者_Go百科ern() method, but it\'s public native String intern();

I tried to look at Java's String#int开发者_Go百科ern() method, but it's public native String intern();

In general, how is interning implemented? In String's case?


For Sun Java, start with JVM_InternString, on line ~3639 of jvm.cpp. Technically, the actual String method is in java/lang/String.c, but it immediately calls JVM_InternString. You can continue to StringTable::intern in symbolTable.cpp.

In a more abstract sense, the purpose of interning is to map equivalent strings to a single canonical one.

0

精彩评论

暂无评论...
验证码 换一张
取 消