diff --git a/.github/workflows/release_config.json b/.github/workflows/release_config.json
index 7ddd165c..f0d4b5b2 100644
--- a/.github/workflows/release_config.json
+++ b/.github/workflows/release_config.json
@@ -27,6 +27,10 @@
{
"title": "## \uD83D\uDEE0 Other Updates",
"labels": ["other", "kind/dependency-change"]
+ },
+ {
+ "title": "## 🚨 Breaking Changes",
+ "labels": ["breaking"]
}
],
"ignore_labels": [
diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs
deleted file mode 100644
index a40ec5db..00000000
--- a/.settings/org.eclipse.buildship.core.prefs
+++ /dev/null
@@ -1,13 +0,0 @@
-arguments=
-auto.sync=false
-build.scans.enabled=false
-connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
-connection.project.dir=
-eclipse.preferences.version=1
-gradle.user.home=
-java.home=
-jvm.arguments=
-offline.mode=false
-override.workspace.settings=false
-show.console.view=true
-show.executions.view=true
diff --git a/src/main/java/com/ibm/cldk/CodeAnalyzer.java b/src/main/java/com/ibm/cldk/CodeAnalyzer.java
index 2490e57d..1a1f54fc 100644
--- a/src/main/java/com/ibm/cldk/CodeAnalyzer.java
+++ b/src/main/java/com/ibm/cldk/CodeAnalyzer.java
@@ -46,7 +46,7 @@ class VersionProvider implements CommandLine.IVersionProvider {
public String[] getVersion() throws Exception {
String version = getClass().getPackage().getImplementationVersion();
- return new String[]{version != null ? version : "unknown"};
+ return new String[] { version != null ? version : "unknown" };
}
}
@@ -56,34 +56,43 @@ public String[] getVersion() throws Exception {
@Command(name = "codeanalyzer", mixinStandardHelpOptions = true, sortOptions = false, versionProvider = VersionProvider.class, description = "Analyze java application.")
public class CodeAnalyzer implements Runnable {
- @Option(names = {"-i", "--input"}, description = "Path to the project root directory.")
+ @Option(names = { "-i", "--input" }, description = "Path to the project root directory.")
private static String input;
- @Option(names = {"-t", "--target-files"}, description = "Paths to files to be analyzed from the input application.")
+ @Option(names = { "-t",
+ "--target-files" }, description = "Paths to files to be analyzed from the input application.")
private static List targetFiles;
- @Option(names = {"-s", "--source-analysis"}, description = "Analyze a single string of java source code instead the project.")
+ @Option(names = { "-s",
+ "--source-analysis" }, description = "Analyze a single string of java source code instead the project.")
private static String sourceAnalysis;
- @Option(names = {"-o", "--output"}, description = "Destination directory to save the output graphs. By default, the SDG formatted as a JSON will be printed to the console.")
+ @Option(names = { "-o",
+ "--output" }, description = "Destination directory to save the output graphs. By default, the SDG formatted as a JSON will be printed to the console.")
private static String output;
- @Option(names = {"-b", "--build-cmd"}, description = "Custom build command. Defaults to auto build.")
+ @Option(names = { "-b", "--build-cmd" }, description = "Custom build command. Defaults to auto build.")
private static String build;
- @Option(names = {"--no-build"}, description = "Do not build your application. Use this option if you have already built your application.")
+ @Option(names = {
+ "--no-build" }, description = "Do not build your application. Use this option if you have already built your application.")
private static boolean noBuild = false;
- @Option(names = {"--no-clean-dependencies"}, description = "Do not attempt to auto-clean dependencies")
+ @Option(names = { "--no-clean-dependencies" }, description = "Do not attempt to auto-clean dependencies")
public static boolean noCleanDependencies = false;
- @Option(names = {"-f", "--project-root-path"}, description = "Path to the root pom.xml/build.gradle file of the project.")
+ @Option(names = { "-f",
+ "--project-root-path" }, description = "Path to the root pom.xml/build.gradle file of the project.")
public static String projectRootPom;
- @Option(names = {"-a", "--analysis-level"}, description = "Level of analysis to perform. Options: 1 (for just symbol table) or 2 (for call graph). Default: 1")
+ @Option(names = { "-a",
+ "--analysis-level" }, description = "Level of analysis to perform. Options: 1 (for just symbol table) or 2 (for call graph). Default: 1")
private static int analysisLevel = 1;
- @Option(names = {"-v", "--verbose"}, description = "Print logs to console.")
+ @Option(names = { "--include-test-classes" }, hidden = true, description = "Print logs to console.")
+ public static boolean includeTestClasses = false;
+
+ @Option(names = { "-v", "--verbose" }, description = "Print logs to console.")
private static boolean verbose = false;
private static final String outputFileName = "analysis.json";
@@ -121,11 +130,13 @@ private static void analyze() throws Exception {
JsonObject combinedJsonObject = new JsonObject();
Map symbolTable;
projectRootPom = projectRootPom == null ? input : projectRootPom;
- // First of all if, sourceAnalysis is provided, we will analyze the source code instead of the project.
+ // First of all if, sourceAnalysis is provided, we will analyze the source code
+ // instead of the project.
if (sourceAnalysis != null) {
// Construct symbol table for source code
Log.debug("Single file analysis.");
- Pair
+ *
+ * @author Rahul Krishna
+ * @version 2.3.0
+ */
@Data
public class Callable {
+ /** The file path where the callable entity is defined. */
private String filePath;
+
+ /** The signature of the callable entity. */
private String signature;
- private String comment;
+
+ /** A list of comments associated with the callable entity. */
+ private List comments;
+
+ /** A list of annotations applied to the callable entity. */
private List annotations;
+
+ /** A list of modifiers applied to the callable entity (e.g., public, private). */
private List modifiers;
+
+ /** A list of exceptions thrown by the callable entity. */
private List thrownExceptions;
+
+ /** The declaration of the callable entity. */
private String declaration;
+
+ /** A list of parameters for the callable entity. */
private List parameters;
+
+ /** The code of the callable entity. */
private String code;
+
+ /** The starting line number of the callable entity in the source file. */
private int startLine;
+
+ /** The ending line number of the callable entity in the source file. */
private int endLine;
+
+ /** The return type of the callable entity. */
private String returnType = null;
+
+ /** Indicates whether the callable entity is implicit. */
private boolean isImplicit = false;
+
+ /** Indicates whether the callable entity is a constructor. */
private boolean isConstructor = false;
+
+ /** A list of types referenced by the callable entity. */
private List referencedTypes;
+
+ /** A list of fields accessed by the callable entity. */
private List accessedFields;
+
+ /** A list of call sites within the callable entity. */
private List callSites;
+
+ /** A list of variable declarations within the callable entity. */
private List variableDeclarations;
+
+ /** A list of CRUD operations associated with the callable entity. */
private List crudOperations = new ArrayList<>();
+
+ /** A list of CRUD queries associated with the callable entity. */
private List crudQueries = new ArrayList<>();
+
+ /** The cyclomatic complexity of the callable entity. */
private int cyclomaticComplexity;
+
+ /** Indicates whether the callable entity is an entry point. */
private boolean isEntrypoint = false;
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/ibm/cldk/entities/Comment.java b/src/main/java/com/ibm/cldk/entities/Comment.java
new file mode 100644
index 00000000..e248a1a0
--- /dev/null
+++ b/src/main/java/com/ibm/cldk/entities/Comment.java
@@ -0,0 +1,80 @@
+package com.ibm.cldk.entities;
+
+import lombok.Data;
+
+/**
+ * Represents a comment entity extracted from source code.
+ * This class encapsulates information about the content, position,
+ * and type of a comment within a source file.
+ *
+ *
+ * The comment can be of various types, including Javadoc, block comments, or line comments.
+ * The class also keeps track of the comment's position within the file (line and column numbers).
+ *
+ *
+ *
+ * This class leverages Lombok's {@code @Data} annotation to automatically generate
+ * getters, setters, {@code toString()}, {@code equals()}, and {@code hashCode()} methods.
+ *
+ *
+ * Example usage:
+ *
+ * Comment comment = new Comment();
+ * comment.setContent("This is a sample comment.");
+ * comment.setStartLine(10);
+ * comment.setEndLine(12);
+ * comment.setJavadoc(true);
+ *
+ *
+ * @author Rahul Krishna
+ * @version 2.3.0
+ */
+@Data
+public class Comment {
+
+ /**
+ * The textual content of the comment.
+ */
+ private String content;
+
+ /**
+ * The starting line number of the comment in the source file.
+ *
+ * Defaults to {@code -1} if the position is unknown.
+ *
+ */
+ private int startLine = -1;
+
+ /**
+ * The ending line number of the comment in the source file.
+ *
+ * Defaults to {@code -1} if the position is unknown.
+ *
+ */
+ private int endLine = -1;
+
+ /**
+ * The starting column number of the comment in the source file.
+ *
+ * Defaults to {@code -1} if the position is unknown.
+ *
+ */
+ private int startColumn = -1;
+
+ /**
+ * The ending column number of the comment in the source file.
+ *
+ * Defaults to {@code -1} if the position is unknown.
+ *
+ */
+ private int endColumn = -1;
+
+ /**
+ * Indicates whether the comment is a Javadoc comment.
+ *
+ * Javadoc comments are special block comments used for generating documentation
+ * and typically start with {@code /**}.
+ *
+ */
+ private boolean isJavadoc = false;
+}
diff --git a/src/main/java/com/ibm/cldk/entities/Field.java b/src/main/java/com/ibm/cldk/entities/Field.java
index 40a8bba9..c8cc0cc5 100644
--- a/src/main/java/com/ibm/cldk/entities/Field.java
+++ b/src/main/java/com/ibm/cldk/entities/Field.java
@@ -5,7 +5,7 @@
@Data
public class Field {
- private String comment;
+ private Comment comment;
private String name;
private String type;
private Integer startLine;
diff --git a/src/main/java/com/ibm/cldk/entities/InitializationBlock.java b/src/main/java/com/ibm/cldk/entities/InitializationBlock.java
new file mode 100644
index 00000000..d10e1f56
--- /dev/null
+++ b/src/main/java/com/ibm/cldk/entities/InitializationBlock.java
@@ -0,0 +1,24 @@
+package com.ibm.cldk.entities;
+
+import lombok.Data;
+
+import java.util.List;
+import java.util.stream.Collector;
+
+@Data
+public class InitializationBlock {
+ private String filePath;
+ private List comments;
+ private List annotations;
+ private List thrownExceptions;
+ private String code;
+ private int startLine;
+ private int endLine;
+ private boolean isStatic;
+ private List referencedTypes;
+ private List accessedFields;
+ private List callSites;
+ private List variableDeclarations;
+ private int cyclomaticComplexity;
+
+}
diff --git a/src/main/java/com/ibm/cldk/entities/JavaCompilationUnit.java b/src/main/java/com/ibm/cldk/entities/JavaCompilationUnit.java
index 2ed0095e..526ee978 100644
--- a/src/main/java/com/ibm/cldk/entities/JavaCompilationUnit.java
+++ b/src/main/java/com/ibm/cldk/entities/JavaCompilationUnit.java
@@ -1,13 +1,16 @@
package com.ibm.cldk.entities;
import lombok.Data;
+
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Data
public class JavaCompilationUnit {
private String filePath;
- private String comment;
+ private String packageName;
+ private List comments = new ArrayList<>();
private List imports;
private Map typeDeclarations;
private boolean isModified;
diff --git a/src/main/java/com/ibm/cldk/entities/ParameterInCallable.java b/src/main/java/com/ibm/cldk/entities/ParameterInCallable.java
index 85cdc321..985c0c1f 100644
--- a/src/main/java/com/ibm/cldk/entities/ParameterInCallable.java
+++ b/src/main/java/com/ibm/cldk/entities/ParameterInCallable.java
@@ -4,14 +4,60 @@
import java.util.List;
+/**
+ * Represents a parameter in a callable entity (e.g., method or constructor).
+ *
+ *
+ * This class encapsulates information about the parameter's type, name, annotations,
+ * modifiers, and its position within the source file.
+ *
+ *
+ *
+ * This class leverages Lombok's {@code @Data} annotation to automatically generate
+ * getters, setters, {@code toString()}, {@code equals()}, and {@code hashCode()} methods.
+ *
+ *
+ *
+ * Example usage:
+ *
+ * ParameterInCallable param = new ParameterInCallable();
+ * param.setType("String");
+ * param.setName("exampleParam");
+ * param.setAnnotations(Arrays.asList("NotNull"));
+ * param.setModifiers(Arrays.asList("final"));
+ * param.setStartLine(10);
+ * param.setEndLine(10);
+ * param.setStartColumn(5);
+ * param.setEndColumn(20);
+ *
+ *
+ *
+ * @author Rahul Krishna
+ * @version 2.3.0
+ */
@Data
public class ParameterInCallable {
+ /** The type of the parameter (e.g., int, String). */
private String type;
+
+ /** The name of the parameter. */
private String name;
+
+ /** A list of annotations applied to the parameter. */
private List annotations;
+
+ /** A list of modifiers applied to the parameter (e.g., final, static). */
private List modifiers;
+
+ /** The starting line number of the parameter in the source file. */
private int startLine;
+
+ /** The ending line number of the parameter in the source file. */
private int endLine;
+
+ /** The starting column number of the parameter in the source file. */
private int startColumn;
+
+ /** The ending column number of the parameter in the source file. */
private int endColumn;
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/ibm/cldk/entities/RecordComponent.java b/src/main/java/com/ibm/cldk/entities/RecordComponent.java
index 586da61c..814d711e 100644
--- a/src/main/java/com/ibm/cldk/entities/RecordComponent.java
+++ b/src/main/java/com/ibm/cldk/entities/RecordComponent.java
@@ -5,13 +5,55 @@
import java.util.ArrayList;
import java.util.List;
+/**
+ * Represents a component of a record in the source code.
+ *
+ *
+ * This class encapsulates information about the component's name, type, modifiers,
+ * annotations, default value, and whether it is a varargs parameter.
+ *
+ *
+ *
+ * This class leverages Lombok's {@code @Data} annotation to automatically generate
+ * getters, setters, {@code toString()}, {@code equals()}, and {@code hashCode()} methods.
+ *
+ *
+ *
+ * Example usage:
+ *
+ * RecordComponent component = new RecordComponent();
+ * component.setName("exampleComponent");
+ * component.setType("String");
+ * component.setModifiers(Arrays.asList("private"));
+ * component.setAnnotations(Arrays.asList("NotNull"));
+ * component.setDefaultValue("defaultValue");
+ * component.setVarArgs(false);
+ *
+ *
+ *
+ * @author Rahul Krishna
+ * @version 2.3.0
+ */
@Data
public class RecordComponent {
- private String comment;
+ /** The comment associated with the record component. */
+ private Comment comment;
+
+ /** The name of the record component. */
private String name;
+
+ /** The type of the record component. */
private String type;
+
+ /** A list of modifiers applied to the record component (e.g., final, static). */
private List modifiers;
+
+ /** A list of annotations applied to the record component. */
private List annotations = new ArrayList<>();
- private Object defaultValue = null; // We will store the string representation of the default value
+
+ /** The default value of the record component, stored as a string representation. */
+ private Object defaultValue = null;
+
+ /** Indicates whether the record component is a varargs parameter. */
private boolean isVarArgs = false;
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/ibm/cldk/entities/Type.java b/src/main/java/com/ibm/cldk/entities/Type.java
index d6ce7290..39b82236 100644
--- a/src/main/java/com/ibm/cldk/entities/Type.java
+++ b/src/main/java/com/ibm/cldk/entities/Type.java
@@ -7,26 +7,75 @@
import java.util.List;
import java.util.Map;
+/**
+ * Represents a type in the system with various characteristics.
+ * This class uses Lombok's @Data annotation to generate boilerplate code.
+ *
+ * @author Rahul Krishna
+ * @version 2.3.0
+ */
@Data
public class Type {
+ /** Indicates if this type is nested. */
private boolean isNestedType;
+
+ /** Indicates if this type is a class or interface declaration. */
private boolean isClassOrInterfaceDeclaration;
+
+ /** Indicates if this type is an enum declaration. */
private boolean isEnumDeclaration;
+
+ /** Indicates if this type is an annotation declaration. */
private boolean isAnnotationDeclaration;
+
+ /** Indicates if this type is a record declaration. */
private boolean isRecordDeclaration;
+
+ /** Indicates if this type is an interface. */
private boolean isInterface;
+
+ /** Indicates if this type is an inner class. */
private boolean isInnerClass;
+
+ /** Indicates if this type is a local class. */
private boolean isLocalClass;
+
+ /** List of types that this type extends. */
private List extendsList = new ArrayList<>();
- private String comment;
+
+ /** List of comments associated with this type. */
+ private List comments;
+
+ /** List of interfaces that this type implements. */
private List implementsList = new ArrayList<>();
+
+ /** List of modifiers for this type. */
private List modifiers = new ArrayList<>();
+
+ /** List of annotations for this type. */
private List annotations = new ArrayList<>();
+
+ /** The parent type of this type. */
private String parentType;
+
+ /** List of nested type declarations within this type. */
private List nestedTypeDeclarations = new ArrayList<>();
+
+ /** Map of callable declarations within this type. */
private Map callableDeclarations = new HashMap<>();
+
+ /** List of field declarations within this type. */
private List fieldDeclarations = new ArrayList<>();
+
+ /** List of enum constants within this type. */
private List enumConstants = new ArrayList<>();
+
+ /** List of record components within this type. */
private List recordComponents = new ArrayList<>();
+
+ /** List of initialization blocks within this type. */
+ private List initializationBlocks = new ArrayList<>();
+
+ /** Indicates if this type is an entry point class. */
private boolean isEntrypointClass = false;
}
\ No newline at end of file
diff --git a/src/main/java/com/ibm/cldk/entities/VariableDeclaration.java b/src/main/java/com/ibm/cldk/entities/VariableDeclaration.java
index 6263c6e4..c9284aea 100644
--- a/src/main/java/com/ibm/cldk/entities/VariableDeclaration.java
+++ b/src/main/java/com/ibm/cldk/entities/VariableDeclaration.java
@@ -2,13 +2,60 @@
import lombok.Data;
+/**
+ * Represents a variable declaration in the source code.
+ *
+ *
+ * This class encapsulates information about the variable's name, type, initializer,
+ * and its position within the source file. It also includes an optional comment
+ * associated with the variable declaration.
+ *
+ *
+ *
+ * This class leverages Lombok's {@code @Data} annotation to automatically generate
+ * getters, setters, {@code toString()}, {@code equals()}, and {@code hashCode()} methods.
+ *
+ *
+ *
+ * Example usage:
+ *
+ * VariableDeclaration varDecl = new VariableDeclaration();
+ * varDecl.setName("exampleVar");
+ * varDecl.setType("String");
+ * varDecl.setInitializer("\"defaultValue\"");
+ * varDecl.setStartLine(10);
+ * varDecl.setEndLine(10);
+ * varDecl.setStartColumn(5);
+ * varDecl.setEndColumn(20);
+ *
+ *
+ *
+ * @author Rahul Krishna
+ * @version 2.3.0
+ */
@Data
public class VariableDeclaration {
+ /** The comment associated with the variable declaration. */
+ private Comment comment;
+
+ /** The name of the variable. */
private String name;
+
+ /** The type of the variable. */
private String type;
+
+ /** The initializer of the variable, stored as a string representation. */
private String initializer;
- private int startLine;
- private int startColumn;
- private int endLine;
- private int endColumn;
+
+ /** The starting line number of the variable declaration in the source file. */
+ private int startLine = -1;
+
+ /** The starting column number of the variable declaration in the source file. */
+ private int startColumn = -1;
+
+ /** The ending line number of the variable declaration in the source file. */
+ private int endLine = -1;
+
+ /** The ending column number of the variable declaration in the source file. */
+ private int endColumn = -1;
}
diff --git a/src/main/java/com/ibm/cldk/utils/AnalysisUtils.java b/src/main/java/com/ibm/cldk/utils/AnalysisUtils.java
index 6400c4e6..957e46d9 100644
--- a/src/main/java/com/ibm/cldk/utils/AnalysisUtils.java
+++ b/src/main/java/com/ibm/cldk/utils/AnalysisUtils.java
@@ -15,6 +15,7 @@
import static com.ibm.cldk.SymbolTable.declaredMethodsAndConstructors;
import com.ibm.cldk.entities.Callable;
+import com.ibm.cldk.entities.Comment;
import com.ibm.cldk.entities.ParameterInCallable;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IMethod;
@@ -61,7 +62,7 @@ public static Map createAndPutNewCallableInSymbolTable(IMethod m
newCallable.setFilePath("");
newCallable.setImplicit(true);
newCallable.setConstructor(methodName.contains(""));
- newCallable.setComment("");
+ newCallable.setComments(new ArrayList<>());
newCallable.setModifiers(Stream.of(method.isPublic() ? "public" : null, method.isProtected() ? "protected" : null, method.isPrivate() ? "private" : null, method.isAbstract() ? "abstract" : null, method.isStatic() ? "static" : null, method.isFinal() ? "final" : null, method.isSynchronized() ? "synchronized" : null, method.isNative() ? "native" : null, method.isSynthetic() ? "synthetic" : null, method.isBridge() ? "bridge" : null).filter(Objects::nonNull).collect(Collectors.toList()));
newCallable.setCode("");
newCallable.setSignature(methodSignature);
diff --git a/src/main/java/com/ibm/cldk/utils/BuildProject.java b/src/main/java/com/ibm/cldk/utils/BuildProject.java
index afc88ed5..b76cc4b9 100644
--- a/src/main/java/com/ibm/cldk/utils/BuildProject.java
+++ b/src/main/java/com/ibm/cldk/utils/BuildProject.java
@@ -1,7 +1,5 @@
package com.ibm.cldk.utils;
-import com.ibm.cldk.CodeAnalyzer;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
@@ -17,6 +15,7 @@
import static com.ibm.cldk.utils.ProjectDirectoryScanner.classFilesStream;
import static com.ibm.cldk.CodeAnalyzer.projectRootPom;
import static com.ibm.cldk.CodeAnalyzer.noCleanDependencies;
+import static com.ibm.cldk.CodeAnalyzer.includeTestClasses;
public class BuildProject {
public static Path libDownloadPath;
@@ -140,7 +139,14 @@ private static boolean mavenBuild(String projectPath) {
Log.info("Checking if Maven is installed.");
return false;
}
- String[] mavenCommand = {MAVEN_CMD, "clean", "compile", "-f", projectPath + "/pom.xml", "-B", "-V", "-e", "-Drat.skip", "-Dfindbugs.skip", "-Dcheckstyle.skip", "-Dpmd.skip=true", "-Dspotbugs.skip", "-Denforcer.skip", "-Dmaven.javadoc.skip", "-DskipTests", "-Dmaven.test.skip.exec", "-Dlicense.skip=true", "-Drat.skip=true", "-Dspotless.check.skip=true"};
+
+ String[] mavenCommand;
+ if (includeTestClasses) {
+ Log.warn("Hidden flag `--include-test-classes` is turned on. We'll including test classes in WALA analysis");
+ mavenCommand = new String[]{MAVEN_CMD, "clean", "test-compile", "-f", projectPath + "/pom.xml", "-B", "-V", "-e", "-Drat.skip", "-Dfindbugs.skip", "-Dcheckstyle.skip", "-Dpmd.skip=true", "-Dspotbugs.skip", "-Denforcer.skip", "-Dmaven.javadoc.skip", "-DskipTests", "-Dmaven.test.skip.exec", "-Dlicense.skip=true", "-Drat.skip=true", "-Dspotless.check.skip=true"};
+ }
+ else
+ mavenCommand = new String[]{MAVEN_CMD, "clean", "compile", "-f", projectPath + "/pom.xml", "-B", "-V", "-e", "-Drat.skip", "-Dfindbugs.skip", "-Dcheckstyle.skip", "-Dpmd.skip=true", "-Dspotbugs.skip", "-Denforcer.skip", "-Dmaven.javadoc.skip", "-DskipTests", "-Dmaven.test.skip.exec", "-Dlicense.skip=true", "-Drat.skip=true", "-Dspotless.check.skip=true"};
return buildWithTool(mavenCommand);
}
@@ -151,7 +157,12 @@ public static boolean gradleBuild(String projectPath) {
if (GRADLE_CMD.equals("gradlew") || GRADLE_CMD.equals("gradlew.bat")) {
gradleCommand = new String[]{projectPath + File.separator + GRADLE_CMD, "clean", "compileJava", "-p", projectPath};
} else {
- gradleCommand = new String[]{GRADLE_CMD, "clean", "compileJava", "-p", projectPath};
+ if (includeTestClasses) {
+ Log.warn("Hidden flag `--include-test-classes` is turned on. We'll including test classes in WALA analysis");
+ gradleCommand = new String[]{GRADLE_CMD, "clean", "compileTestJava", "-p", projectPath};
+ }
+ else
+ gradleCommand = new String[]{GRADLE_CMD, "clean", "compileJava", "-p", projectPath};
}
return buildWithTool(gradleCommand);
}
diff --git a/src/main/java/com/ibm/cldk/utils/ProjectDirectoryScanner.java b/src/main/java/com/ibm/cldk/utils/ProjectDirectoryScanner.java
index a4314822..c10752ed 100644
--- a/src/main/java/com/ibm/cldk/utils/ProjectDirectoryScanner.java
+++ b/src/main/java/com/ibm/cldk/utils/ProjectDirectoryScanner.java
@@ -9,20 +9,15 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import static com.ibm.cldk.CodeAnalyzer.includeTestClasses;
+
public class ProjectDirectoryScanner {
public static List classFilesStream(String projectPath) throws IOException {
Path projectDir = Paths.get(projectPath).toAbsolutePath();
Log.info("Finding *.class files in " + projectDir);
if (Files.exists(projectDir)) {
try (Stream paths = Files.walk(projectDir)) {
- return paths.filter(file -> !Files.isDirectory(file) && file.toString().endsWith(".class"))
- .filter(file -> {
- // Let's find the path relative to the project directory
- Path relativePath = projectDir.relativize(file.toAbsolutePath());
- String relativePathAsString = relativePath.toString().replace("\\", "/"); // Windows fix
- return !relativePathAsString.contains("test/resources/") && !relativePathAsString.contains("main/resources/");
- })
- .collect(Collectors.toList());
+ return paths.filter(file -> !Files.isDirectory(file) && file.toString().endsWith(".class")).collect(Collectors.toList());
}
}
return null;
@@ -47,13 +42,13 @@ public static List sourceFilesStream(String projectPath) throws IOExceptio
if (Files.exists(projectDir)) {
try (Stream paths = Files.walk(projectDir)) {
return paths
- .filter(file -> !Files.isDirectory(file))
- .filter(file -> file.toString().endsWith(".java"))
- .filter(file -> !file.toAbsolutePath().toString().contains("build/"))
- .filter(file -> !file.toAbsolutePath().toString().contains("target/"))
- .filter(file -> !file.toAbsolutePath().toString().contains("main/resources/"))
- .filter(file -> !file.toAbsolutePath().toString().contains("test/resources/"))
- .collect(Collectors.toList());
+ .filter(file -> !Files.isDirectory(file))
+ .filter(file -> file.toString().endsWith(".java"))
+ .filter(file -> !file.toAbsolutePath().toString().contains("build/"))
+ .filter(file -> !file.toAbsolutePath().toString().contains("target/"))
+ .filter(file -> !file.toAbsolutePath().toString().contains("main/resources/"))
+ .filter(file -> !file.toAbsolutePath().toString().contains("test/resources/"))
+ .collect(Collectors.toList());
}
}
return null;
diff --git a/src/test/java/com/ibm/cldk/CodeAnalyzerIntegrationTest.java b/src/test/java/com/ibm/cldk/CodeAnalyzerIntegrationTest.java
index 24f1975a..2fcbc836 100644
--- a/src/test/java/com/ibm/cldk/CodeAnalyzerIntegrationTest.java
+++ b/src/test/java/com/ibm/cldk/CodeAnalyzerIntegrationTest.java
@@ -55,6 +55,7 @@ public class CodeAnalyzerIntegrationTest {
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/plantsbywebsphere")), "/test-applications/plantsbywebsphere")
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/call-graph-test")), "/test-applications/call-graph-test")
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/record-class-test")), "/test-applications/record-class-test")
+ .withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/init-blocks-test")), "/test-applications/init-blocks-test")
.withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/mvnw-working-test")), "/test-applications/mvnw-working-test");
@Container
@@ -332,4 +333,63 @@ void parametersInCallableMustHaveStartAndEndLineAndColumns() throws IOException,
}
}
}
+
+ @Test
+ void mustBeAbleToResolveInitializationBlocks() throws IOException, InterruptedException {
+ var runCodeAnalyzerOnCallGraphTest = container.execInContainer(
+ "bash", "-c",
+ String.format(
+ "export JAVA_HOME=%s && java -jar /opt/jars/codeanalyzer-%s.jar --input=/test-applications/init-blocks-test --analysis-level=1",
+ javaHomePath, codeanalyzerVersion
+ )
+ );
+
+ // Read the output JSON
+ Gson gson = new Gson();
+ JsonObject jsonObject = gson.fromJson(runCodeAnalyzerOnCallGraphTest.getStdout(), JsonObject.class);
+ JsonObject symbolTable = jsonObject.getAsJsonObject("symbol_table");
+ for (Map.Entry element : symbolTable.entrySet()) {
+ String key = element.getKey();
+ if (!key.endsWith("App.java")) {
+ continue;
+ }
+ JsonObject type = element.getValue().getAsJsonObject();
+ if (type.has("type_declarations")) {
+ JsonObject typeDeclarations = type.getAsJsonObject("type_declarations");
+ JsonArray initializationBlocks = typeDeclarations.getAsJsonObject("org.example.App").getAsJsonArray("initialization_blocks");
+ // There should be 2 blocks
+ Assertions.assertEquals(2, initializationBlocks.size(), "Callable should have 1 parameter");
+ Assertions.assertTrue(initializationBlocks.get(0).getAsJsonObject().get("is_static").getAsBoolean(), "Static block should be marked as static");
+ Assertions.assertFalse(initializationBlocks.get(1).getAsJsonObject().get("is_static").getAsBoolean(), "Instance block should be marked as not static");
+ }
+ }
+ }
+
+ @Test
+ void mustBeAbleToExtractCommentBlocks() throws IOException, InterruptedException {
+ var runCodeAnalyzerOnCallGraphTest = container.execInContainer(
+ "bash", "-c",
+ String.format(
+ "export JAVA_HOME=%s && java -jar /opt/jars/codeanalyzer-%s.jar --input=/test-applications/init-blocks-test --analysis-level=1",
+ javaHomePath, codeanalyzerVersion
+ )
+ );
+
+ // Read the output JSON
+ Gson gson = new Gson();
+ JsonObject jsonObject = gson.fromJson(runCodeAnalyzerOnCallGraphTest.getStdout(), JsonObject.class);
+ JsonObject symbolTable = jsonObject.getAsJsonObject("symbol_table");
+ for (Map.Entry element : symbolTable.entrySet()) {
+ String key = element.getKey();
+ if (!key.endsWith("App.java")) {
+ continue;
+ }
+ JsonObject type = element.getValue().getAsJsonObject();
+ JsonArray comments = type.getAsJsonArray("comments");
+ Assertions.assertEquals(16, comments.size(), "Should have 15 comments");
+ Assertions.assertTrue(StreamSupport.stream(comments.spliterator(), false)
+ .map(JsonElement::getAsJsonObject)
+ .anyMatch(comment -> comment.get("is_javadoc").getAsBoolean()), "Single line comment not found");
+ }
+ }
}
diff --git a/src/test/resources/test-applications/init-blocks-test/.gitattributes b/src/test/resources/test-applications/init-blocks-test/.gitattributes
new file mode 100644
index 00000000..f91f6460
--- /dev/null
+++ b/src/test/resources/test-applications/init-blocks-test/.gitattributes
@@ -0,0 +1,12 @@
+#
+# https://help.github.com/articles/dealing-with-line-endings/
+#
+# Linux start script should use lf
+/gradlew text eol=lf
+
+# These are Windows script files and should use crlf
+*.bat text eol=crlf
+
+# Binary files should be left untouched
+*.jar binary
+
diff --git a/src/test/resources/test-applications/init-blocks-test/.gitignore b/src/test/resources/test-applications/init-blocks-test/.gitignore
new file mode 100644
index 00000000..1b6985c0
--- /dev/null
+++ b/src/test/resources/test-applications/init-blocks-test/.gitignore
@@ -0,0 +1,5 @@
+# Ignore Gradle project-specific cache directory
+.gradle
+
+# Ignore Gradle build output directory
+build
diff --git a/src/test/resources/test-applications/init-blocks-test/app/src/main/java/org/example/App.java b/src/test/resources/test-applications/init-blocks-test/app/src/main/java/org/example/App.java
new file mode 100644
index 00000000..bca83ebb
--- /dev/null
+++ b/src/test/resources/test-applications/init-blocks-test/app/src/main/java/org/example/App.java
@@ -0,0 +1,80 @@
+/**
+ * Static and Instance Initialization Blocks Example with comments.
+ *
+ * MIT License
+ *
+ */
+package org.example;
+
+// Import statements
+import java.util.List;
+
+/**
+ * The App class demonstrates the use of static and instance initialization blocks,
+ * as well as a constructor in Java.
+ */
+public class App {
+ // Static field
+ private static String staticMessage;
+
+ // Static initialization block
+ static {
+ try {
+ staticMessage = "Static block initialized";
+ System.out.println("Static initialization block executed.");
+ initializeStaticFields(); // Call a method to initialize static fields
+ } catch (Exception e) {
+ // Handle any exceptions that occur during initialization
+ System.err.println("Error in static block: " + e.getMessage());
+ throw new RuntimeException(e); // Rethrow the exception
+ }
+ }
+
+ // Instance initialization block
+ {
+ try {
+ System.out.println("Instance initialization block executed.");
+ initializeInstanceFields();
+ } catch (Exception e) {
+ System.err.println("Error in instance block: " + e.getMessage());
+ }
+ }
+
+ /**
+ * Constructor for the App class.
+ * Prints a message indicating that the constructor has been executed.
+ */
+ public App() {
+ System.out.println("Constructor executed.");
+ }
+
+ /**
+ * Initializes static fields.
+ * Prints a message indicating that static fields are being initialized.
+ */
+ private static void initializeStaticFields() {
+ System.out.println("Initializing static fields.");
+ }
+
+ /**
+ * Initializes instance fields.
+ * Prints a message indicating that instance fields are being initialized.
+ */
+ private void initializeInstanceFields() {
+ // This is a comment associated with the println statement below
+ System.out.println("Initializing instance fields.");
+ }
+
+ /**
+ * The main method is the entry point of the application.
+ * Creates a new instance of the App class.
+ *
+ * @param args Command line arguments
+ */
+ public static void main(String[] args) {
+
+ // This is an orphaned comment
+
+ new App(); // Create a new instance of the App class
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/test-applications/init-blocks-test/gradle.properties b/src/test/resources/test-applications/init-blocks-test/gradle.properties
new file mode 100644
index 00000000..51540088
--- /dev/null
+++ b/src/test/resources/test-applications/init-blocks-test/gradle.properties
@@ -0,0 +1,7 @@
+# This file was generated by the Gradle 'init' task.
+# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
+
+org.gradle.configuration-cache=true
+org.gradle.parallel=true
+org.gradle.caching=true
+
diff --git a/src/test/resources/test-applications/init-blocks-test/gradlew b/src/test/resources/test-applications/init-blocks-test/gradlew
new file mode 100755
index 00000000..f3b75f3b
--- /dev/null
+++ b/src/test/resources/test-applications/init-blocks-test/gradlew
@@ -0,0 +1,251 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/src/test/resources/test-applications/init-blocks-test/gradlew.bat b/src/test/resources/test-applications/init-blocks-test/gradlew.bat
new file mode 100644
index 00000000..9d21a218
--- /dev/null
+++ b/src/test/resources/test-applications/init-blocks-test/gradlew.bat
@@ -0,0 +1,94 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/src/test/resources/test-applications/init-blocks-test/settings.gradle.kts b/src/test/resources/test-applications/init-blocks-test/settings.gradle.kts
new file mode 100644
index 00000000..d1bf0739
--- /dev/null
+++ b/src/test/resources/test-applications/init-blocks-test/settings.gradle.kts
@@ -0,0 +1,15 @@
+package `test-applications`.`init-blocks-test`/*
+ * This file was generated by the Gradle 'init' task.
+ *
+ * The settings file is used to specify which projects to include in your build.
+ * For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.12.1/userguide/multi_project_builds.html in the Gradle documentation.
+ * This project uses @Incubating APIs which are subject to change.
+ */
+
+plugins {
+ // Apply the foojay-resolver plugin to allow automatic download of JDKs
+ id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
+}
+
+rootProject.name = "record-class-test"
+include("app")