Search code examples
byte-buddy

What is the precise definition of internalName in Byte Buddy?


Byte Buddy's specification (its documentation/javadocs) often refers to internal name.

This term does not appear in either section 6 of the JLS, section 13 of the JLS, or in section 4 of the JVMS, which are the only three places where names are defined.

Often it seems that Byte Buddy uses internal name to mean "binary name", but this too is imprecise. There is the binary name that the JLS defines, and the binary name that the JVMS defines, which applies only to class and interface names. Additionally, Byte Buddy uses internal name in the context of things like methods and fields and such, so it can't mean just "binary name".

So: what is the definition of internal name in Byte Buddy?

My loose guess is: any name, exactly as it appears after decoding and whatnot, in a .class file. So "java/lang/Class" would be an internal name (notably not "java.lang.Class"), and "toString" would be an internal name of the obvious method, and so on. (I don't know what the internal name of an array would be offhand.)

(My next question will be about actual name.)


Solution

  • It's the format that is expected by the ASM library (which is also the format that is written to a class file): https://asm.ow2.io/javadoc/org/objectweb/asm/Type.html#getInternalName()

    Returns the internal name of the class corresponding to this object or array type. The internal name of a class is its fully qualified name (as returned by Class.getName(), where '.' are replaced by '/'). This method should only be used for an object or array type.