I faced the problem to which NullPointerException occurs when 
Handler#getType() method is executed in ExprEditor#edit(Handler). 
Originally, edit(Handler) should hook only catch block.
But, the method hooks the finally block and the synchronized block.

As the result of my own investigation, it turns out that the problem 
is derived from the following specification of the Java class file.

1. The catch block, the finally block, and the synchronized block are stored 
   in the same exception table.

2. There is an area where the type of the exception (name of Exception class)
   is stored in the entry of an exception table.
   
   But, in the finally block and the synchronized block, 0 which means
   arbitrary exceptions is stored.


The code of Handler#getType() is as follows.
public CtClass getType() throws NotFoundException {
  |     ConstPool cp = getConstPool();
  |     String name = cp.getClassInfo(etable.catchType(index));
  |     return Descriptor.toCtClass(name, thisClass.getClassPool());
  | }

In getType() method, ConstPool#getClassInfo() returns null, in case of
the block which is hooked is finally or synchronized. So, NullPointerException
has been generated because the value is referred by Descriptor#toCtClass(). 


To avoid this problem, I propose to check null of the return value of 
ConstPool#getClassInfo() (type of the exception) in the getType() method.

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3877437#3877437

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3877437


-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to