You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Maciej Kwidziński (Jira)" <ji...@apache.org> on 2019/09/30 11:46:00 UTC
[jira] [Commented] (BCEL-314) Expose the true class name
[ https://issues.apache.org/jira/browse/BCEL-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16940897#comment-16940897 ]
Maciej Kwidziński commented on BCEL-314:
----------------------------------------
I started to write a new API (leaving the old one as is).
Intuitively I wanted to add the invariant that {{clazz.getClassName()}} and {{clazz.getLongClassName()}} return equivalent values, e.g. if the first one is {{java.lang.String}}, then the latter one is {{java/lang/String}}.
JavaClass has setters, which requires additional complexity for maintaining invariants. However, I see that invariants are already violated by setters. E.g. one would expect that {{clazz.getClassName()}} and {{clazz.getConstantPool().getConstantString(clazz.getClassNameIndex(), Const.CONSTANT_Class)}} to always return the same value. But calling either {{clazz.setClassName(...)}} or {{clazz.ConstantPool(...)}} can easily violate this expectation. Can such expectations be simply ignored?
> Expose the true class name
> --------------------------
>
> Key: BCEL-314
> URL: https://issues.apache.org/jira/browse/BCEL-314
> Project: Commons BCEL
> Issue Type: Improvement
> Reporter: Maciej Kwidziński
> Priority: Major
>
> Natively, in the bytecode, class names look like this:
> {code:java}
> java/lang/String{code}
> You can see it in {{NoClassDefFoundError}}, etc.
> Bytecode decompilers and other bytecode-engineering libs (like kotlinx-metadata) will use this native format.
> For some reason, [BCEL explicitly converts it to the dot notation|https://commons.apache.org/proper/commons-bcel/apidocs/org/apache/bcel/classfile/Utility.html#compactClassName-java.lang.String-boolean-]:
> {quote}
> Shorten long class names, _java/lang/String_ becomes _java.lang.String_
> {quote}
> I'm not sure how is that shorter, but it definitely makes interoperability harder, ie. if you want to base Java-specific bytecode engineering with BCEL and still reuse Kotlin-specific libraries for Kotlin-specific bytecode.
> Could JavaClass expose the real, actual, bytecode-level class name?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)