Sample

int-4682d20b1569-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines73

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8510–1; higher is more readable
Dorn0.4580–1; higher is more readable
Mi0.2550–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol18.330–20; mean of three runs
BTTF0.5310–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 < 0x0) ? "" : classFullName.substring(0x0, 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.1646.493−54.334
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.851−7.276

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

Score0.851

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.861+0.609
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.167 (log-odds).
Score = sigmoid(-0.167) = 0.458.

Score0.255
Score16
Run 1

The code is well-structured with clear separation of concerns, organized imports, and meaningful method grouping. Nesting is minimal except for a necessary try-catch in the initialize method. Intent is clearly expressed through descriptive method names, Javadoc comments, and focused helper functions. Code length is concise but not overly compressed; each method accomplishes its task efficiently. Action granularity follows one-action-per-line in most cases, particularly in the newProxy method where the proxy creation is broken into logical steps. Reading flow is natural—methods progress from simple operations to more complex ones, with appropriate documentation guiding the reader. Minor points: the use of hex literals (0x0) is slightly unconventional and could use plain zeros; the initialize method's catch block adds slight complexity. Overall, this is exemplary readable code, consistent with Google Guava style standards.

Run 2

The code is generally readable and well-structured. It uses clear method names, concise Javadoc comments, and flat logic with minimal nesting. Each method performs a single, well-defined action, and the reading flow is natural—from package name handling to class initialization and proxy creation. The private constructor and static imports are appropriate for a utility class. Minor issues include the use of hex literals (0x0) instead of plain 0, which slightly obscures intent, and a somewhat long Javadoc for initialize(). Additionally, the proxy creation line is relatively verbose, but still clear. Overall, the code is clean and maintainable.

Run 3

The code is highly readable. Structure is logical with clear utility class organization, static imports, and Javadoc documentation. Methods are flat with minimal nesting; only a simple loop and try-catch exist, both easy to follow. Intent is explicit in method names and documentation. Code is concise without being cryptic, especially the package-name extraction. Each line generally performs one action, particularly in the proxy creation. Reading flow is natural: package declaration, imports, class, then methods in logical order. Minor points: the hexadecimal literals (0x0) are slightly unusual but harmless; the initialize method's exception handling is a bit dense but still clear. Overall, excellent readability and maintainability.

Run 1

Code Structure: A well-organized utility class with focused methods, related overloads grouped together, and a private constructor. Nesting: Mostly flat; the loop containing try/catch in initialize is shallow and appropriate. Clarity of intent: Descriptive method and parameter names, explicit validation, and informative Javadoc make purposes clear. Hexadecimal 0x0 unnecessarily obscures ordinary zero values, and object is a generic local name. Code length: Implementations are concise; documentation is extensive but useful, with some repetition between overloads. Action granularity: Statements generally perform one clear action each, and the multiline proxy construction remains a single coherent operation. Reading flow: Consistent formatting and straightforward delegation, validation, construction, and return sequences support natural reading. Minor import-spacing and literal-style issues prevent a perfect score.

Run 2

Code Structure: Well-organized utility class with focused methods, adjacent overloads, and a private constructor. Nesting: Mostly flat; the loop with try/catch adds only modest, necessary nesting. Clarity of intent: Descriptive method names and detailed Javadoc clearly explain behavior; hexadecimal zero literals (0x0) are unnecessarily distracting, and 'object' is a generic variable name. Code length: Implementations are concise, though documentation is somewhat verbose and repetitive. Action granularity: Each statement performs a distinct step, with validation, proxy creation, and casting separated cleanly. Reading flow: Methods follow a natural sequence and formatting is consistent overall; missing blank lines between the package declaration and import groups slightly reduce visual separation.

Run 3

Code Structure: Well-organized utility class with focused methods and a private constructor. Nesting: Mostly flat; the loop and try/catch in initialize add only modest depth. Clarity of intent: Descriptive method names and thorough Javadoc make behavior clear, although hexadecimal zero literals are unnecessarily unusual and the local name object is generic. Code length: Implementations are concise; documentation is extensive but useful. Action granularity: Each statement performs a distinct operation, with validation, proxy creation, and casting separated. Reading flow: Related overloads are adjacent and methods follow a consistent layout. Minor distractions include missing spacing between package and imports and the awkward multiline proxy assignment.