minor corrections
This commit is contained in:
parent
f7de5a6e43
commit
8fcf99e6b6
2 changed files with 74 additions and 29 deletions
BIN
report.pdf
BIN
report.pdf
Binary file not shown.
103
report.tex
103
report.tex
|
@ -57,27 +57,52 @@ requirements:
|
|||
\item 50.000 or more lines of code.
|
||||
\end{itemize}
|
||||
|
||||
Additionally, we added some (less strict) constraints that we thought would lead to a more significant and influential analysis:
|
||||
Additionally, we added some less strict constraints that we thought would lead
|
||||
to a more significant and influential analysis:
|
||||
|
||||
\begin{itemize}
|
||||
\item There must be evidence that the project follows business-oriented conventions.
|
||||
This excludes amateur or personal projects that might have fewer design pattern applications due to their nature.
|
||||
\item Repository data, documentation, and comments must be written in English. Many repositories that are at the top of the search results provided by the hard requirements are not in English, and this drastically hampers our ability to understand the code;
|
||||
\item The artifact the project produces must not rely on external components and have a streamlined build process, with all code stored in a single Maven/Gradle module. This improves our ability to tinker with the project more quickly and the pattern detection process, which requires all \textit{.class} files related to the project to be stored in a single directory tree.
|
||||
\item There must be evidence that the project follows business-oriented
|
||||
conventions. This excludes amateur or personal projects that might have
|
||||
fewer design pattern applications due to their nature.
|
||||
\item Repository data, documentation, and comments must be written in English.
|
||||
Many repositories that are at the top of the search results provided by the
|
||||
hard requirements are not in English, and this drastically hampers our
|
||||
ability to understand the code;
|
||||
\item The artifact the project produces must not rely on external components
|
||||
and have a streamlined build process, with all code stored in a single
|
||||
Maven/Gradle module. This improves our ability to tinker with the project
|
||||
more quickly and the pattern detection process, which requires all
|
||||
\textit{.class} files related to the project to be stored in a single
|
||||
directory tree.
|
||||
\end{itemize}
|
||||
|
||||
Additionally, instead of querying GitHub directly for projects, we decided to see if libraries we knew already in our Java development career would match the hard and soft requirements we set for ourselves.
|
||||
Additionally, instead of querying GitHub directly for projects, we decided to
|
||||
see if libraries we knew already in our Java development career would match the
|
||||
hard and soft requirements we set for ourselves.
|
||||
|
||||
Therefore, we considered the following GitHub repositories:
|
||||
|
||||
\begin{description}
|
||||
\item[vavr-io/vavr] a Java library for functional programming, was discarded as the project is less than 20.000 lines of code and does not meet the rigid requirements;
|
||||
\item[bitcoin4j/bitcoin4j] a Java implementation of the bitcoin protocol, discarded as the project is distributed in several subprojects, and therefore the build process is nontrivial;
|
||||
\item[FasterXML/jackson-core] is the core ''module`` of a Java JSON serialization and deserialization library. We chose this project because it meets the selection criteria. It does not rely on external components for its execution. Finally, the project structure uses a single Maven module for its sources and is thus easy to analyze.
|
||||
\item[vavr-io/vavr] a Java library for functional programming, was discarded
|
||||
as the project is less than 20.000 lines of code and does not meet the rigid
|
||||
requirements;
|
||||
\item[bitcoin4j/bitcoin4j] a Java implementation of the bitcoin protocol,
|
||||
discarded as the project is distributed in several subprojects, and
|
||||
therefore the build process is nontrivial;
|
||||
\item[FasterXML/jackson-core] is the core ''module`` of a Java JSON
|
||||
serialization and deserialization library. We chose this project because it
|
||||
meets the selection criteria. It does not rely on external components for
|
||||
its execution. Finally, the project structure uses a single Maven module for
|
||||
its sources and is thus easy to analyze.
|
||||
\end{description}
|
||||
|
||||
\subsection {The Jackson Core Project}
|
||||
As mentioned, Jackson is a library that offers serialization and deserialization capabilities in JSON format. It is highly extensible and customizable through a robust but flexible API. The library is divided into what the Jackson developers call “modules,” i.e., plug-ins that can augment the serialization and deserialization process. Some modules, like the \textit{jackson-dataformat-xml} module, target different encoding languages like XML.
|
||||
As mentioned, Jackson is a library that offers serialization and deserialization
|
||||
capabilities in JSON format. It is highly extensible and customizable through a
|
||||
robust but flexible API. The library is divided into what the Jackson developers
|
||||
call “modules,” i.e., plug-ins that can augment the serialization and
|
||||
deserialization process. Some modules, like the \textit{jackson-dataformat-xml}
|
||||
module, target different encoding languages like XML.
|
||||
|
||||
The chosen repository contains only the \textit{core} module of Jackson. The
|
||||
\textit{core} module implements the necessary library abstractions and
|
||||
|
@ -92,10 +117,11 @@ version available at the time of writing.
|
|||
|
||||
After verifying that the project meets the hard requirements related to GitHub
|
||||
(more than 2000 stars, more than 600 forks, 35 open issues\footnote{as of
|
||||
2022-10-19}), we ensured that the project had enough lines of code by using the
|
||||
cloc tool, which provided the following output shown in Figure \ref{fig:cloc}.
|
||||
By looking at the results we can finally assert that the project contains 58.787
|
||||
lines of Java code and this satisfies all the requirements.
|
||||
2022-10-19 (ISO 8601 date)}), we ensured that the project had enough lines of
|
||||
code by using the cloc tool, which provided the following output shown in Figure
|
||||
\ref{fig:cloc}. By looking at the results we can finally assert that the
|
||||
project contains 58.787 lines of Java code and this satisfies all the
|
||||
requirements.
|
||||
|
||||
\begin{figure}[H]
|
||||
\centering
|
||||
|
@ -120,28 +146,49 @@ lines of Java code and this satisfies all the requirements.
|
|||
Total & 5158 & 27431 & 255936 & 2048305\\
|
||||
\bottomrule
|
||||
\end{tabular}
|
||||
\caption{Output of the \textit{cloc} tool for the Jackson Core project at revision
|
||||
\textit{jackson-core-3.13.4}.}
|
||||
\caption{Output of the \textit{cloc} tool for the Jackson Core project at
|
||||
revision \textit{jackson-core-3.13.4}.}
|
||||
\label{fig:cloc}
|
||||
\end{figure}
|
||||
|
||||
\section{TO REWRITE Analysis Implementation}
|
||||
\section{Analysis Implementation}
|
||||
|
||||
We use
|
||||
\href{https://users.encs.concordia.ca/~nikolaos/pattern\_detection.html}{\textit{Pattern4J}}
|
||||
as a pattern detection tool. This tool needs to be compiled \textit{.class} files to perform analysis.
|
||||
Therefore, as \textit{jackson-core} is a standard Maven project, we compile the sources using the command mvn clean compile.
|
||||
The \textit{pom.xml} of the library specifies Java 1.6 as a build target, which is not supported by JDK 17 or above. We used JDK 11 instead, as it is the previous LTS version.
|
||||
The analysis is performed using the
|
||||
\textit{Pattern4J}\footnote{\url{https://users.encs.concordia.ca/~nikolaos/pattern\_detection.html}}
|
||||
developed at Concordia University. This program attempts to detect traditional
|
||||
design patterns by scanning the bytecode (i.e.\ the \texttt{.class} files) of a
|
||||
given project and by checking several heuristics. Due to the unceirtanty of this
|
||||
process we double-check each instance of a pattern found to use our own
|
||||
judgement and detect possible false positives.
|
||||
|
||||
An XML dump of the \textit{Pattern4j} analysis results is included in the submission as the file \textit{analysis.xml}.
|
||||
Since the tool needs compiled \textit{.class} files to perform the analysis,
|
||||
and since \textit{jackson-core} is a standard Maven project, we compile the
|
||||
sources using the command \texttt{mvn clean compile}. The \textit{pom.xml} of
|
||||
the library specifies Java 1.6 as a build target, which is not supported by JDK
|
||||
17 or above. We used JDK 11 instead, as it is the most recent LTS version of the
|
||||
JDK to still support this target.
|
||||
|
||||
An XML dump of the \textit{Pattern4j} analysis results is included in the
|
||||
submission as the file \textit{analysis.xml}.
|
||||
|
||||
In the following sections each detection of the \textit{Pattern4J}
|
||||
tool is reviewed to characterize if it is indeed not a false positive and if the
|
||||
design pattern is varied in any way in its application. For the sake of brevity,
|
||||
when referring to a class by its fully-qualified nomain name the prefix
|
||||
\textit{com.fasterxml.jackson.core} is omitted as all classes in the Jackson
|
||||
core project reside in this package or in a sub-package of this package.
|
||||
|
||||
\section{Structural Patterns}
|
||||
|
||||
\subsection{TO REWRITE Singleton Pattern}
|
||||
Ensure a class only has one instance and provide a global point of access to it.
|
||||
The tool found thirteen instances with the Singleton pattern.
|
||||
Doing a deeper analysis of the found instances, we discovered that some results are false positives.
|
||||
Example, \textit{com.fasterxml.jackson.core.sym.Name1} has a private package constructor and a public static final instance of it, but reading the documentation, the class represents (short) JSON string literals and is initialized by client code.
|
||||
|
||||
Ensure a class only has one instance and provide a global point of access to it.
|
||||
The tool found thirteen instances with the Singleton pattern. Doing a deeper
|
||||
analysis of the found instances, we discovered that some results are false
|
||||
positives. Example, \textit{sym.Name1} has a private
|
||||
package constructor and a public static final instance of it, but reading the
|
||||
documentation, the class represents (short) JSON string literals and is
|
||||
initialized by client code.
|
||||
|
||||
\begin{lstlisting}[caption=Name1 class,language=java]
|
||||
public final class Name1 extends Name {
|
||||
|
@ -179,8 +226,6 @@ public final class Name1 extends Name {
|
|||
}
|
||||
\end{lstlisting}
|
||||
|
||||
(com.fasterxml.jackson.core omitted for brevity)
|
||||
|
||||
\begin{description}
|
||||
\item[sym.Name1, JsonLocation, DefaultIndenter,
|
||||
util.DefaultPrettyPrinter\$FixedSpaceIndenter] is not a singleton (detected cause of "convenient" default instance given as static final field), the constructor is not used, but the class is extensible
|
||||
|
|
Reference in a new issue