Sample

int-5a4f95e5855c-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines73

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8580–1; higher is more readable
Dorn0.4580–1; higher is more readable
Mi0.2650–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro18.330–20; mean of three runs
GPT-6.1 Sol190–20; mean of three runs
BTTF0.7280–1; higher is more readable

Views

Source code

package com.google.common.reflect; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; /** * Static utilities relating to Java reflection. * * @since 12.0 */ public final class Reflection { /** * Returns the package name of {@code clazz} according to the Java Language Specification (section * 6.7). Unlike {@link Class#getPackage}, this method only parses the class name, without * attempting to define the {@link Package} and hence load files. */ public static String getPackageName(Class<?> clazz) { return getPackageName(clazz.getName()); } /** * Returns the package name of {@code classFullName} according to the Java Language Specification * (section 6.7). Unlike {@link Class#getPackage}, this method only parses the class name, without * attempting to define the {@link Package} and hence load files. */ public static String getPackageName(String classFullName) { int lastDot = classFullName.lastIndexOf('.'); return (lastDot < 0) ? "" : classFullName.substring(0, lastDot); } /** * Ensures that the given classes are initialized, as described in <a * href="http://java.sun.com/docs/books/jls/third_edition/html/execution.html#12.4.2">JLS Section * 12.4.2</a>. * * <p>WARNING: Normally it's a smell if a class needs to be explicitly initialized, because static * state hurts system maintainability and testability. In cases when you have no choice while * interoperating with a legacy framework, this method helps to keep the code less ugly. * * @throws ExceptionInInitializerError if an exception is thrown during initialization of a class */ public static void initialize(Class<?>... classes) { for (Class<?> clazz : classes) { try { Class.forName(clazz.getName(), true, clazz.getClassLoader()); } catch (ClassNotFoundException e) { throw new AssertionError(e); } } } /** * Returns a proxy instance that implements {@code interfaceType} by dispatching method * invocations to {@code handler}. The class loader of {@code interfaceType} will be used to * define the proxy class. To implement multiple interfaces or specify a class loader, use {@link * Proxy#newProxyInstance}. * * @throws IllegalArgumentException if {@code interfaceType} does not specify the type of a Java * interface */ public static <T> T newProxy(Class<T> interfaceType, InvocationHandler handler) { checkNotNull(handler); checkArgument(interfaceType.isInterface(), "%s is not an interface", interfaceType); Object object = Proxy.newProxyInstance( interfaceType.getClassLoader(), new Class<?>[] {interfaceType}, handler); return interfaceType.cast(object); } private Reflection() {} }

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.1628.86−53.752
Source linesThe number of non-empty source lines.73+29.2
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.846−7.269

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

Score0.858

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.74−1.584
Indentation frequencyHow rapidly indentation changes from line to line.43+0.75
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.90.622+0.658
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.72.802+0.608
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.99.959−0.569
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.43−0.566
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.049+0.464

Intercept 0.07 + feature contributions = -0.169 (log-odds).
Score = sigmoid(-0.169) = 0.458.

Score0.265
Score16
Run 1

The code is highly readable. It has clear logical organization with a single utility class and well-separated static methods. Nesting is minimal, with only one level inside loops or conditionals. Each method has a clear purpose, supported by concise Javadoc comments that explain intent and edge cases. Code length is appropriate and avoids unnecessary verbosity. Action granularity is excellent — most lines perform a single operation, and line breaks in method calls improve clarity. The reading flow is natural, progressing from simpler to more complex methods, with private constructor at the end. Minor deductions include the slightly dense ternary in getPackageName and the wrapped Proxy.newProxyInstance call, which, while formatted well, still requires careful reading.

Run 2

This code is highly readable. The structure is logical, with clear public methods and a private constructor preventing instantiation. Javadocs are concise and informative, clearly stating purpose and edge cases. Nesting is minimal, limited to a try-catch inside a loop and a single ternary expression. Each method performs a clear, single action. Line length and formatting are consistent with Java standards. The only minor drawback is the slightly long Javadoc for initialize(), but it provides necessary context and warnings. Overall, the code is easy to understand and maintain.

Run 3

The code is exceptionally readable due to its clean, well-structured organization, clear intent, and concise implementation. Each method has a single, focused responsibility, and the use of Javadoc enhances clarity. Nesting is minimal, and actions are generally one per line, contributing to a natural reading flow. The code length is appropriate—no unnecessary verbosity. Only minor points prevent a perfect score: the ternary in getPackageName and the slightly verbose javadoc comments, but these do not materially impact readability.

Run 1

Code Structure: A well-organized utility class with focused methods, adjacent overloads, and a private constructor. Nesting: Minimal; only initialization uses a loop containing try/catch. Clarity of intent: Descriptive method names and detailed Javadoc make behavior and constraints explicit, though the variable name 'object' is generic. Code length: Implementation is concise; documentation is somewhat lengthy but useful. Action granularity: Each statement performs a distinct action, with validation, proxy creation, and casting clearly separated. Reading flow: Methods follow a natural progression, and consistent formatting supports easy scanning. Minor drawbacks include missing spacing between package and import sections and slightly verbose documentation.

Run 2

Code Structure: Well-organized utility class with focused methods, related overloads grouped together, and a private constructor. Nesting: Minimal; only initialization uses a loop with a straightforward try/catch. Clarity of intent: Descriptive method and parameter names, explicit validation, and informative Javadoc make behavior clear. Code length: Implementations are concise; documentation is somewhat lengthy but explains important reflection semantics. Action granularity: Each statement performs a distinct action, with no crowded multi-statement lines. Reading flow: Methods follow natural sequences, including validation, proxy creation, and casting. Minor readability weaknesses include missing spacing between the package and import sections and the generic local name 'object' rather than 'proxy'.

Run 3

Code Structure: A well-organized utility class with small, focused methods and a private constructor. Nesting: Mostly flat; only initialize uses a modest loop with try/catch. Clarity of intent: Descriptive method and parameter names, explicit validation, and informative Javadoc make behavior clear; the local name object is slightly generic. Code length: Implementations are concise, though documentation is comparatively lengthy and partly repetitive. Action granularity: Each statement performs a distinct operation, with readable wrapping of the proxy creation call. Reading flow: Related overloads appear together, and methods proceed naturally from inputs through processing to results. Minor formatting issues, such as missing separation between the package declaration and imports, slightly reduce polish.