nhatminhle / cofoja

Contracts for Java
GNU Lesser General Public License v3.0
151 stars 18 forks source link

NPE in LineNumberingMethodAdapter#onMethodEnter when using the Eclipse compiler #17

Closed nhatminhle closed 9 years ago

nhatminhle commented 9 years ago

From fst...@gmail.com on February 06, 2011 10:25:49

When running the annotation processor with the Eclipse compiler (ecj.jar), upon executing the contracted code a null pointer exception is thrown in LineNumberingMethodAdapter#onMethodEnter. The attached patch adds an extra null check, which makes it work for me in Eclipse.

Attachment: cofoja-npe-ecj.patch

Original issue: http://code.google.com/p/cofoja/issues/detail?id=10

nhatminhle commented 9 years ago

From nhat.min...@gmail.com on February 06, 2011 10:58:52

Indeed, the check is made in visitLocalVariable() below and not in onMethodEnter(). I've rearranged the patch so it looks like the code in visitLocalVariable() but otherwise it should work now in r67 . Can you confirm?

Also, this seems to indicate that Eclipse does not support the javac extension APIs, which means that among other things, line numbering won't work properly (e.g. in the stack traces when an exception is thrown for contract violation). Am I right? Maybe it exposes its own API; since Eclipse is so widely used, it could be worthwhile to add support, though I don't know much about Eclipse.

Status: Fixed
Owner: nhat.minh.le

nhatminhle commented 9 years ago

From fst...@gmail.com on February 06, 2011 12:06:53

Yes, it works with ecj in r67 and there are no line numbers for annotations in stack traces for contract violations.

I don't really know any details about this, but I suppose if it was supported in ecj it would be available using the same API as in javac, so my guess is it isn't supported yet.

Many thanks for fixing this so quickly!