[jboss-jira] [JBoss JIRA] (JASSIST-263) ClassPool cannot read generated classes
Shigeru Chiba (JIRA)
issues at jboss.org
Thu Sep 8 15:04:00 EDT 2016
[ https://issues.jboss.org/browse/JASSIST-263?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13290846#comment-13290846 ]
Shigeru Chiba commented on JASSIST-263:
---------------------------------------
That is right behavior. First of all, BuildingClassLoader does not keep a given class file by defineClass(). So returning no URL is correct behavior. To address this, ClassPool should keep it for further accesses but your implementation creates a new instance of ClassPool, which does not remember a class file generated before.
A quick fix is to make {{pool}} be a field in {{BuildClassLoader}}.
> ClassPool cannot read generated classes
> ---------------------------------------
>
> Key: JASSIST-263
> URL: https://issues.jboss.org/browse/JASSIST-263
> Project: Javassist
> Issue Type: Bug
> Affects Versions: 3.20.0-GA
> Reporter: Paul Pogonyshev
> Assignee: Shigeru Chiba
> Attachments: JavassistBug.java
>
>
> ClassPool.get() cannot retrieve classes that are in turn generated at runtime. For example, if I try to define at runtime two classes, one of which extends another, the base will not be found, even though it can be retrieved just fine from my class loader. See the attached example.
> As far as I could trace it, the issue comes from ClassPoolTail.find() returning a null URL for the class. This is understandable, since class definition doesn't exist as a file --- it is generated at runtime. However, ClassPool.get() should still succeed for classes that have no URL, yet can be found through its ClassLoader.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list