Sample

int-11eb81eaf9fb-SRC

Unmodified source class

Lines61

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.6420–1; higher is more readable
Dorn0.4240–1; higher is more readable
Mi0.0550–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.4880–1; higher is more readable

Views

Source code

package io.netty.channel.socket.nio; import io.netty.channel.socket.SocketProtocolFamily; import io.netty.util.internal.PlatformDependent; import io.netty.util.internal.logging.InternalLogger; import io.netty.util.internal.logging.InternalLoggerFactory; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.StandardProtocolFamily; import java.nio.channels.Channel; import java.nio.channels.SocketChannel; import java.nio.channels.spi.SelectorProvider; final class SelectorProviderUtil { private static final InternalLogger logger = InternalLoggerFactory.getInstance(SelectorProviderUtil.class); static Method findOpenMethod(String methodName) { if (PlatformDependent.javaVersion() >= 15) { try { return SelectorProvider.class.getMethod(methodName, java.net.ProtocolFamily.class); } catch (Throwable e) { logger.debug("SelectorProvider.{}(ProtocolFamily) not available, will use default", methodName, e); } } return null; } /** * Use the {@link SelectorProvider} to open {@link SocketChannel} and so remove condition in * {@link SelectorProvider#provider()} which is called by each SocketChannel.open() otherwise. * <p> * See <a href="https://github.com/netty/netty/issues/2308">#2308</a>. */ private static <C extends Channel> C newChannel(Method method, SelectorProvider provider, Object family) throws IOException { if (family != null && method != null) { try { @SuppressWarnings("unchecked") C channel = (C) method.invoke(provider, family); return channel; } catch (InvocationTargetException | IllegalAccessException e) { throw new IOException(e); } } return null; } static <C extends Channel> C newChannel(Method method, SelectorProvider provider, SocketProtocolFamily family) throws IOException { if (family != null) { return newChannel(method, provider, family.toJdkFamily()); } return null; } static <C extends Channel> C newDomainSocketChannel(Method method, SelectorProvider provider) throws IOException { return newChannel(method, provider, StandardProtocolFamily.valueOf("UNIX")); } private SelectorProviderUtil() { } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.2345.937−77.416
Source linesThe number of non-empty source lines.61+24.4
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.633−6.949

Intercept 8.87 + feature contributions = -51.095 (log-odds).
Score = sigmoid(-51.095) = 0.

Score0.642

Feature contributions

FeatureValueContribution
(log-odds)
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.117.952−1.331
Indentation frequencyHow rapidly indentation changes from line to line.56+1.2
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.62−1.159
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.117.871+1.097
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.56−0.864
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.60.857+0.441
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.072+0.239

Intercept 0.07 + feature contributions = -0.306 (log-odds).
Score = sigmoid(-0.306) = 0.424.

Score0.055
Score21
Run 1

The code is well-structured and highly readable. It is organized logically with clear separation of concerns: one public helper method, one private overloaded method, and a small wrapper. Nesting is minimal, with only one level of try-catch inside an if-block. Intent is clear from method names and comments; the Javadoc explains the rationale for using SelectorProvider directly. Code length is appropriate, with no unnecessary repetition. Action granularity is generally good, with one operation per line, although method.invoke and assignment are combined in one line, which slightly reduces readability. Reading flow is natural, moving from version check to method resolution to invocation. Error handling is concise and consistent. Overall, the code is easy to follow, well-documented, and maintains a clean separation of logic, with only minor room for improvement in granularity of the reflective call.

Run 2

The code is well-structured with clear separation of concerns: method lookup, generic channel creation, and specific protocol family handling. Nesting is minimal — only one level of conditional checking within methods, and no deep indentation or nested control flow beyond the try-catch block. Each method has a clear single purpose, making intent obvious from names like `findOpenMethod`, `newChannel`, and `newDomainSocketChannel`. Lines are concise, with one action per statement in most cases, especially in the reflection invocation. The reading flow is natural: helper methods are ordered logically from low-level lookup to higher-level protocol-specific wrappers. The only minor deductions are the slightly long generic method signature and the Javadoc link comment that interrupts flow, but overall the code is highly readable.

Run 3

The code is well-structured and readable. It uses clear method names, logical organization, and has minimal nesting. The intent is evident: finding and invoking selector provider methods for different protocol families. However, there are minor readability issues: the overloaded `newChannel` methods could be confusing regarding which one is called, and the generic type parameter `<C extends Channel>` with unchecked casting adds slight complexity. The Javadoc comment provides useful context for the optimization. Overall, the code is concise, has good action granularity, and follows a natural reading flow, but the reflective invocation and method overloading slightly hinder clarity.

Run 1

Code Structure: A focused utility class separates method discovery, reflective channel creation, and protocol-family conversion cleanly. Nesting: Shallow conditionals and try/catch blocks keep complexity low. Clarity of intent: Descriptive names and documentation convey the purpose, though reflection, generic casts, and null-based fallback behavior require some interpretation. Code length: Concise, with little unnecessary code. Action granularity: Statements generally perform one action per line. Reading flow: Methods follow a logical progression from discovery to channel creation, but inconsistent parameter indentation and the lack of spacing after the package declaration slightly reduce polish. The documentation explains the optimization but does not clearly describe null returns or the Java-version compatibility strategy.

Run 2

Code Structure: A focused utility class with small, logically separated methods and centralized reflective invocation. Nesting: Shallow overall; conditionals containing try/catch blocks introduce only modest nesting. Clarity of intent: Descriptive method names and the explanatory comment communicate the purpose, although reflection, generic casts, and null-based fallback behavior require closer reading. Code length: Concise without unnecessary repetition; overloads reuse the shared helper effectively. Action granularity: Statements generally perform one action per line, making execution easy to follow. Reading flow: Method ordering naturally progresses from method discovery to channel creation and specialized wrappers. Minor distractions include inconsistent parameter indentation, tightly packed package/import declarations, and a somewhat awkward comment. The distinction between unavailable functionality and absent arguments could be documented more explicitly.

Run 3

Code Structure: A focused utility class with small methods and centralized reflective channel creation provides logical organization. Nesting: Limited to conditionals containing try/catch blocks; easy to follow. Clarity of intent: Descriptive method names and documentation explain the purpose, though reflection, generic casts, and null fallback behavior require some interpretation. Code length: Concise, with little unnecessary code and useful delegation between overloads. Action granularity: Statements generally perform one action per line, keeping operations distinct. Reading flow: Methods progress naturally from method discovery to channel creation and specialized helpers. Minor formatting issues, including missing separation after the package declaration and inconsistent continuation indentation, reduce polish. The Object family parameter and undocumented null returns slightly weaken readability.