I'm working on an analysis for Java programs that requires side-effect information about method calls. For standard library classes, I would like to compile a list of methods with read-only parameters. That is, methods that don't modify their arguments, or anything reachable from their arguments. I can infer a lot from the javadocs, but that will take time.
Could anyone suggest an easier reference or method for determining whether standard method calls modify their arguments? Is reading through the each javadoc entry really the best way?
Thanks!
EDIT: A bonus would be identifying methods that have no side-effects on the object either. For instance, stack.pop() would whereas stack.size() would not.
A side effect is anything a method does besides computing and returning a value. Any change of instance or class field values is a side effect, as is drawing something on the screen, writing to a file or a network connection.
Side effects can be unavoidable: Get(x); changes the state of the input. Put(x); changes the state of the output.
Well, all methods taking only primitive types/strings/Object/generic types as parameters should satisfy you without further consideration. And for java.lang and java.util this should cover most of the methods.
But you'd really better to limit packages you want to process, because standard jdk offers huge library of classes for all tasks and purposes.
edit
It's somewhat fuzzier for generic types declared as E extends ModifiableObject
, so see for yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With