Bug in generated code? [message #1782367] |
Thu, 22 February 2018 07:03  |
Eclipse User |
|
|
|
Hello,
I'm trying to figure out yet another discrepancy between interpreted and compiled OCL. It seems that despite guarding for null in the invariant, the generated code accesses properties too eagerly resulting in NPE. In the attached example, the problem can be seen in org.eclipse.ocl.standalone.javaMM/javaMM.impl.MethodInvocationImpl.java#doesNotCallExit (line 431), where the "method" property is null. Both Complete OCL, interpreted OCLinEcore and EVL handle this as expected, so I can only presume it's a bug rather than semantic differences between OCLinEcore and Complete OCL.
Thanks,
Sina
|
|
|
|
|
|
|
Re: Bug in generated code? [message #1782386 is a reply to message #1782384] |
Thu, 22 February 2018 10:14  |
Eclipse User |
|
|
|
Hi
If your import is from Modisco and the [1]'s are a fiction,. I would certainly recommend changing every non-Collection to [?].
Use of null values in Collections is rare, and arguably illegal in UML, so the default null-free Collections should probably be left as is.
As you write, a downside is that null checks cannot be bypassed during evaluation.
Another downside is that the OCL is fragile. Looking for examples in your code, it doesn't seem too bad since you get a lot of solid non-null values from collection iterators.
Once every non-collection can be null, many class-typed property accesses will be diagnosed (and the limited known-nullness checks will be stressed to correctly exploit e.g. "method.modifier <> null" guards). I steadily improve the depth of the null-safe analysis, but it's not perfect.
It really depends what sort of quality you are looking for. Given that your file name is java-findbugs, I presume you want rather good quality.
Regards
Ed Willink
|
|
|
Powered by
FUDForum. Page generated in 0.04504 seconds