From 5d7f0773da07afa7b5e87950ff7ecc68c883ca08 Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Sat, 6 Nov 2021 21:16:42 +0100 Subject: [PATCH] implements getCanonicalName() --- .../nativecode/ReplacementForClass.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/de/inetsoftware/jwebassembly/module/nativecode/ReplacementForClass.java b/src/de/inetsoftware/jwebassembly/module/nativecode/ReplacementForClass.java index 5a6a289..31e4eb6 100644 --- a/src/de/inetsoftware/jwebassembly/module/nativecode/ReplacementForClass.java +++ b/src/de/inetsoftware/jwebassembly/module/nativecode/ReplacementForClass.java @@ -318,6 +318,35 @@ class ReplacementForClass { return simpleName.substring( index ); } + /** + * Replacement of the Java method getCanonicalName() + * + * @return the canonical name of the underlying class + */ + public String getCanonicalName() { + String canonicalName; + if( isArray() ) { + canonicalName = getComponentType().getCanonicalName(); + if( canonicalName != null ) + return canonicalName + "[]"; + else + return null; + } + canonicalName = getName(); + int idx = canonicalName.indexOf( '$' ); + if( idx >= 0 ) { + idx++; + if( idx < canonicalName.length() ) { + char ch = canonicalName.charAt( idx ); + if( '0' <= ch && ch <= '9' ) { + return null; + } + } + return canonicalName.replace( '$', '.' ); + } + return canonicalName; + } + /** * Replacement of the Java method getMethod() */