[jira] [Commented] (BCEL-336) MethodGen throws NullPointerException upon Invalid Class File Missing Constructor Body

2020-04-14 Thread Tomo Suzuki (Jira)


[ 
https://issues.apache.org/jira/browse/BCEL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17083605#comment-17083605
 ] 

Tomo Suzuki commented on BCEL-336:
--

The master passed my test case. Thank you for quick turnaround.

> 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
> Attachments: Screen Shot 2020-04-14 at 10.43.31.png
>
>  Time Spent: 10m
>  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)


[jira] [Commented] (BCEL-336) MethodGen throws NullPointerException upon Invalid Class File Missing Constructor Body

2020-04-14 Thread Tomo Suzuki (Jira)


[ 
https://issues.apache.org/jira/browse/BCEL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17083603#comment-17083603
 ] 

Tomo Suzuki commented on BCEL-336:
--

{{org.apache.bcel.classfile.ClassFormatException}} looks more specific.

{code:java}
/**
 * Thrown when the BCEL attempts to read a class file and determines
 * that the file is malformed or otherwise cannot be interpreted as a
 * class file.
 *
 */
public class ClassFormatException extends RuntimeException {
...
{code}

IllegalStateException also sounds good for me.

> 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
> Attachments: Screen Shot 2020-04-14 at 10.43.31.png
>
>  Time Spent: 10m
>  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)


[jira] [Commented] (BCEL-336) MethodGen throws NullPointerException upon Invalid Class File Missing Constructor Body

2020-04-14 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/BCEL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17083562#comment-17083562
 ] 

Gary D. Gregory commented on BCEL-336:
--

[~suztomo]
How about throwing an {{IllegalStateException}} instead?
Gary

> 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
> Attachments: Screen Shot 2020-04-14 at 10.43.31.png
>
>  Time Spent: 10m
>  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)


[jira] [Commented] (BCEL-336) MethodGen throws NullPointerException upon Invalid Class File Missing Constructor Body

2020-04-14 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/BCEL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17083561#comment-17083561
 ] 

Gary D. Gregory commented on BCEL-336:
--

Mercifully, Eclipse does not blow up:
{noformat}
// Compiled from MailDateFormat.java (version 1.6 : 50.0, super bit)
public class javax.mail.internet.MailDateFormat extends 
java.text.SimpleDateFormat {
  
  // Field descriptor #4 J
  private static final long serialVersionUID = -8148227605210628779L;
  
  // Field descriptor #9 Z
  static boolean debug;
  
  // Field descriptor #11 Ljava/util/TimeZone;
  private static java.util.TimeZone tz;
  
  // Field descriptor #13 Ljava/util/Calendar;
  private static java.util.Calendar cal;
  
  // Method descriptor #15 ()V
  public MailDateFormat();
  
  // Method descriptor #17 
(Ljava/util/Date;Ljava/lang/StringBuffer;Ljava/text/FieldPosition;)Ljava/lang/StringBuffer;
  public java.lang.StringBuffer format(java.util.Date arg0, 
java.lang.StringBuffer arg1, java.text.FieldPosition arg2);
  
  // Method descriptor #19 
(Ljava/lang/String;Ljava/text/ParsePosition;)Ljava/util/Date;
  public java.util.Date parse(java.lang.String arg0, java.text.ParsePosition 
arg1);
  
  // Method descriptor #21 ([CLjava/text/ParsePosition;Z)Ljava/util/Date;
  private static java.util.Date parseDate(char[] arg0, java.text.ParsePosition 
arg1, boolean arg2);
  
  // Method descriptor #23 (IIIZ)Ljava/util/Date;
  private static synchronized java.util.Date ourUTC(int arg0, int arg1, int 
arg2, int arg3, int arg4, int arg5, int arg6, boolean arg7);
  
  // Method descriptor #25 (Ljava/util/Calendar;)V
  public void setCalendar(java.util.Calendar arg0);
  
  // Method descriptor #27 (Ljava/text/NumberFormat;)V
  public void setNumberFormat(java.text.NumberFormat arg0);
  
  // Method descriptor #15 ()V
  static {};
}
{noformat}


> 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
> Attachments: Screen Shot 2020-04-14 at 10.43.31.png
>
>  Time Spent: 10m
>  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)


[jira] [Commented] (BCEL-336) MethodGen throws NullPointerException upon Invalid Class File Missing Constructor Body

2020-04-14 Thread Tomo Suzuki (Jira)


[ 
https://issues.apache.org/jira/browse/BCEL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17083483#comment-17083483
 ] 

Tomo Suzuki commented on BCEL-336:
--

Created https://github.com/apache/commons-bcel/pull/43

> 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
> Attachments: Screen Shot 2020-04-14 at 10.43.31.png
>
>  Time Spent: 10m
>  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)


[jira] [Commented] (BCEL-336) MethodGen throws NullPointerException upon Invalid Class File Missing Constructor Body

2020-04-14 Thread Tomo Suzuki (Jira)


[ 
https://issues.apache.org/jira/browse/BCEL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17083474#comment-17083474
 ] 

Tomo Suzuki commented on BCEL-336:
--

Yes, I'll create a PR.

> 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
> Attachments: Screen Shot 2020-04-14 at 10.43.31.png
>
>
> 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)


[jira] [Commented] (BCEL-336) MethodGen throws NullPointerException upon Invalid Class File Missing Constructor Body

2020-04-14 Thread Tomo Suzuki (Jira)


[ 
https://issues.apache.org/jira/browse/BCEL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17083470#comment-17083470
 ] 

Tomo Suzuki commented on BCEL-336:
--

I use 6.4.1:

{noformat}

  org.apache.bcel
  bcel
  6.4.1

{noformat}


> 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
> Attachments: Screen Shot 2020-04-14 at 10.43.31.png
>
>
> 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)


[jira] [Commented] (BCEL-336) MethodGen throws NullPointerException upon Invalid Class File Missing Constructor Body

2020-04-14 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/BCEL-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17083466#comment-17083466
 ] 

Gary D. Gregory commented on BCEL-336:
--

What version of Apache Commons BCEL are you using?

> 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
> Attachments: Screen Shot 2020-04-14 at 10.43.31.png
>
>
> 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)