Sample

int-591b5fdd2bbc-SRC

Unmodified source class

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 Pro180–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

The code is highly readable. It has a clear, logical structure with domain-focused methods and a private constructor preventing instantiation. Nesting is flat, with only a simple try-catch inside a loop. Intent is explicit in method names, parameter names, and detailed Javadoc referencing the JLS. Code length is concise and avoids boilerplate. Action granularity is appropriate, with one main action per line, though the Proxy.newProxyInstance call is slightly multi-line but still clear. Reading flow is natural: package declaration, imports, Javadoc, then methods ordered from simple string parsing to more complex reflection operations. The only minor blemish is the slightly long Javadoc warning paragraph, which could be condensed, but it does not harm readability.

Run 3

The code is highly readable, well-structured, and follows clean coding principles. It consists of a single utility class with clear, focused methods, each performing one logical action (e.g., getting a package name, initializing classes, or creating a proxy). Nesting is minimal—only one loop with a try-catch block and a simple conditional expression. Intents are explicit due to descriptive method names, thorough Javadoc, and use of static imports (checkNotNull, checkArgument) that improve conciseness without sacrificing clarity. The code length is appropriate, avoiding unnecessary verbosity. Reading flow is natural: each method is logically placed and compactly implemented. The only minor deductions are for the slightly dense Javadoc and the multi-line Proxy.newProxyInstance call, but overall this is exemplary readable Java code.

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 clearly explain behavior and constraints, though the local name 'object' is generic. Code length: Implementations are concise; documentation is extensive but useful, with some repetition between overloads. Action granularity: Each statement performs a distinct operation, and the longer proxy creation call is sensibly split across lines. Reading flow: Consistent formatting and straightforward control flow make the code easy to follow; missing spacing between the package declaration and imports is a minor presentation issue.

Run 2

Code Structure: A cohesive utility class with clearly separated methods and a private constructor. Nesting: Mostly flat; initialization adds only a straightforward loop and try/catch. Clarity of intent: Descriptive method and parameter names, informative Javadoc, and explicit validation make behavior easy to understand. Code length: Implementations are concise, although documentation is relatively lengthy and partly repeated across overloads. Action granularity: Each statement performs a focused action; the proxy creation call is sensibly formatted across lines. Reading flow: Methods follow a natural progression, with overloads adjacent and validation preceding proxy creation. Minor readability drawbacks include the generic local name 'object' and the lack of spacing between package and import sections.

Run 3

Code Structure: Well-organized utility class with focused methods and a private constructor. Nesting: Minimal; only initialization uses a loop containing straightforward try/catch handling. Clarity of intent: Descriptive method names, explicit validation, and informative Javadocs make purposes clear, though the proxy variable 'object' is generic. Code length: Implementations are concise; documentation is somewhat lengthy but useful. Action granularity: Each statement performs a distinct operation, with appropriate line wrapping for the proxy creation call. Reading flow: Consistent formatting and logical method grouping support natural reading; missing spacing between package and import groups is a minor presentation issue.