Skip to content

'$' characters in class names are converted to '.' in joinpoint's 'toString' method #351

@kriegaex

Description

@kriegaex

I just had a case in which my execution pointcut explicitly targeted a JDK proxy. When logging the joinpoint during advice execution, the $ had been replaced by .. During LTW, the class name was still displayed correctly.

[AppClassLoader@18b4aac2] weaveinfo at Type 'jdk.proxy2.$Proxy92' (no debug info available)::0 Join point 'method-execution(long jdk.proxy2.$Proxy92.getCount())' in Type 'jdk.proxy2.$Proxy92' (no debug info available) advised by before advice from 'uk.vaent.aspect.MyAspect' (MyAspect.java) [with runtime test]
	see also: uk\vaent\aspect\MyAspect.java::0
execution(long jdk.proxy2..Proxy92.getCount())

See? execution(long jdk.proxy2.$Proxy92.getCount()) during weaving, but execution(long jdk.proxy2..Proxy92.getCount()) during advice execution.

The root cause seems to be here:

String makeTypeName(Class<?> type, String typeName, boolean shortName) {
if (type == null) return "ANONYMOUS";
if (type.isArray()) {
Class<?> componentType = type.getComponentType();
return makeTypeName(componentType, componentType.getName(), shortName) + "[]";
}
if (shortName) {
return stripPackageName(typeName).replace('$', '.');
} else {
return typeName.replace('$', '.');
}
}

What exactly is the reason for the .replace('$', '.')? This behaviour traces back to the initial version 23 years ago.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions