求问String::lines方法的实现位置,已尝试OpenJDK仓库未找到
Locating the Implementation of
String::lines Hey there! I can help you find where the String::lines method is implemented in OpenJDK. Here's what you need to know:
- First, note the version context: The
lines()method was added in JDK 11, which corresponds to the JDK-8200425 issue you referenced. Make sure you're looking at a JDK 11 (or newer) branch/release of the OpenJDK repository—this is probably why you didn't find it earlier when browsing the repo root. - Exact source file path: The implementation lives in the
Stringclass source file at this path within the OpenJDK repository:src/java.base/share/classes/java/lang/String.java - Finding the method in the file: Once you open that file, search for the method signature:
Its implementation uses internal string splitting logic (leveragingpublic Stream<String> lines()StringSplitterunder the hood) to split the string along line terminators and return a stream of the resulting lines. - Accessing the right repo branch: If you're using the web interface, navigate to the JDK 11 branch (e.g.,
jdk11orjdk11u) instead of the default main branch. If cloning locally with Mercurial, target the JDK 11 branch of the OpenJDK repo.
That should get you straight to the implementation you're looking for!
内容的提问来源于stack exchange,提问作者MartyIX
相关产品推荐
相关产品推荐

