You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2020/04/15 13:02:00 UTC
[jira] [Resolved] (BCEL-336) MethodGen throws NullPointerException
upon Invalid Class File Missing Constructor Body
[ https://issues.apache.org/jira/browse/BCEL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary D. Gregory resolved BCEL-336.
----------------------------------
Fix Version/s: 6.4.2
Resolution: Fixed
> MethodGen throws NullPointerException upon Invalid Class File Missing Constructor Body
> --------------------------------------------------------------------------------------
>
> Key: BCEL-336
> URL: https://issues.apache.org/jira/browse/BCEL-336
> Project: Commons BCEL
> Issue Type: Task
> Reporter: Tomo Suzuki
> Priority: Major
> Fix For: 6.4.2
>
> Attachments: Screen Shot 2020-04-14 at 10.43.31.png
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> MethodGen throws NullPointerException upon invalid class file missing constructor body. Should it throw more appropriate exception?
> {{javax:javaee-api:6.0}}'s {{javax.mail.internet.MailDateFormat}} does not have valid constructor body. When I tried to create MethodGen instance for the class, BCEL's MethodGen constructor throws NullPointerException:
> {code:java}
> JavaClass sourceJavaClass = loadJavaClass(sourceClassName);
> ClassGen classGen = new ClassGen(sourceJavaClass);
> for (Method method : sourceJavaClass.getMethods()) {
> MethodGen methodGen = new MethodGen(method, sourceClassName, classGen.getConstantPool());
> ...
> {code}
> NullPointerException is thrown [https://github.com/GoogleCloudPlatform/cloud-opensource-java/issues/1352#issuecomment-613467921]
> The exception comes from {{new InstructionList(m.getCode().getCode()}}, where {{m.getCode()}} returning null.
> Given the class file is malformed (screenshot below), it's understandable for BCEL to throw an exception. Is there more appropriate exception (rather than NullPointerException)?
> !Screen Shot 2020-04-14 at 10.43.31.png|width=857,height=504!
--
This message was sent by Atlassian Jira
(v8.3.4#803005)