]> git.uio.no Git - ifi-stolz-refaktor.git/commitdiff
Thesis: double class instance invocations
authorErlend Kristiansen <erlenkr@ifi.uio.no>
Wed, 16 Apr 2014 16:24:58 +0000 (18:24 +0200)
committerErlend Kristiansen <erlenkr@ifi.uio.no>
Wed, 16 Apr 2014 16:24:58 +0000 (18:24 +0200)
thesis/master-thesis-erlenkr.tex

index abe03ad92463f1db5189c54505d177752837545a..7c3e3d31114466e88ae4fce6f06ebea09ef040fa 100644 (file)
@@ -1653,6 +1653,24 @@ This shows that classes acting as superclasses are especially fragile to
 introducing errors in the context of automated refactoring. This is also shown 
 in bug\ldots \todoin{File Eclipse bug report}
 
+\subsection{A double class instance creation}
+The following is a problem caused solely by the underlying \MoveMethod 
+refactoring.  The problem occurs if two classes are instantiated such that the 
+first constructor invocation is an argument to a second, and that the first 
+constructor invocation takes an argument that is built up using a field. As an 
+example, say that \var{name} is a field of the enclosing class, and we have the 
+expression \code{new A(new B(name))}. If this expression is located in a 
+selection that is moved to another class, \var{name} will be left untouched, 
+instead of being prefixed with a variable of the same type as it is declared in.  
+If \var{name} is the destination for the move, it is not replaced by 
+\code{this}, or removed if it is a prefix to a member access 
+(\code{name.member}), but it is still left by itself.
+
+Situations like this would lead to code that will not compile. Therefore, we 
+have to avoid them by not allowing selections to contain such double class 
+instance creations that also contains references to fields.
+\todoin{File Eclipse bug report}
+
 \subsection{Instantiation of non-static inner class}
 When a non-static inner class is instantiated, this must happen in the scope of 
 its declaring class. This is because it must have access to the members of the 
@@ -3021,6 +3039,17 @@ very simple. It looks for calls to methods that are either protected or
 package-private within the selection, and throws an 
 \type{IllegalExpressionFoundException} if one is found.
 
+\subsection{The DoubleClassInstanceCreationChecker}
+The \type{DoubleClassInstanceCreationChecker} checks that there are no double 
+class instance creations where the inner constructor call take and argument that 
+is built up using field references.
+
+The checker visits all nodes of type \type{ClassInstanceCreation} within a 
+selection. For all of these nodes, if its parent also is a class instance 
+creation, it accepts a visitor that throws a 
+\type{IllegalExpressionFoundException} if it enclounters a name that is a field 
+reference.
+
 \subsection{The InstantiationOfNonStaticInnerClassChecker}
 The \type{InstantiationOfNonStaticInnerClassChecker} checks that selections
 does not contain instantiations of non-static inner classes. The