From 8edf98b983fd7b5e00d5cef0760f57c8935ad3d3 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Wed, 11 Jan 2023 18:51:32 +0100
Subject: [PATCH 01/45] chore(deps): update junit5 monorepo (#5069)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
spoon-dataflow/build.gradle | 2 +-
spoon-pom/pom.xml | 6 +++---
spoon-visualisation/pom.xml | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/spoon-dataflow/build.gradle b/spoon-dataflow/build.gradle
index c26fd2c2564..4c955b25e08 100644
--- a/spoon-dataflow/build.gradle
+++ b/spoon-dataflow/build.gradle
@@ -23,7 +23,7 @@ dependencies {
implementation group: 'fr.inria.gforge.spoon', name: 'spoon-core', version: '+'
implementation group: 'commons-cli', name: 'commons-cli', version: '1.5.0'
implementation group: 'com.microsoft', name: 'z3', version: '4.8.4'
- testImplementation("org.junit.jupiter:junit-jupiter:5.9.1")
+ testImplementation("org.junit.jupiter:junit-jupiter:5.9.2")
}
application {
diff --git a/spoon-pom/pom.xml b/spoon-pom/pom.xml
index 8b898a9c108..697d98c0a31 100644
--- a/spoon-pom/pom.xml
+++ b/spoon-pom/pom.xml
@@ -38,19 +38,19 @@
org.junit.jupiter
junit-jupiter-engine
- 5.9.1
+ 5.9.2
test
org.junit.jupiter
junit-jupiter-params
- 5.9.1
+ 5.9.2
test
org.junit.platform
junit-platform-launcher
- 1.9.1
+ 1.9.2
test
diff --git a/spoon-visualisation/pom.xml b/spoon-visualisation/pom.xml
index c61da8ce8e1..8787353c96f 100644
--- a/spoon-visualisation/pom.xml
+++ b/spoon-visualisation/pom.xml
@@ -190,7 +190,7 @@
org.junit.jupiter
junit-jupiter-engine
- 5.9.1
+ 5.9.2
test
From 613945b496fb9dbb873681635fcc2386273a9822 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 12 Jan 2023 14:22:24 +0100
Subject: [PATCH 02/45] chore(deps): update dependency
org.apache.maven.plugins:maven-dependency-plugin to v3.5.0 (#5076)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
spoon-pom/pom.xml | 2 +-
spoon-visualisation/pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/spoon-pom/pom.xml b/spoon-pom/pom.xml
index 697d98c0a31..be137e98988 100644
--- a/spoon-pom/pom.xml
+++ b/spoon-pom/pom.xml
@@ -244,7 +244,7 @@
maven-dependency-plugin
- 3.4.0
+ 3.5.0
maven-deploy-plugin
diff --git a/spoon-visualisation/pom.xml b/spoon-visualisation/pom.xml
index 8787353c96f..fc3b6e0e55d 100644
--- a/spoon-visualisation/pom.xml
+++ b/spoon-visualisation/pom.xml
@@ -39,7 +39,7 @@
org.apache.maven.plugins
maven-dependency-plugin
- 3.4.0
+ 3.5.0
main deps
From 546f8aef0d30275511e275906696e4a8395f3adc Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 12 Jan 2023 14:22:46 +0100
Subject: [PATCH 03/45] fix(deps): update dependency org.jetbrains:annotations
to v24 (#5072)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
spoon-visualisation/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/spoon-visualisation/pom.xml b/spoon-visualisation/pom.xml
index fc3b6e0e55d..27ad13a7c28 100644
--- a/spoon-visualisation/pom.xml
+++ b/spoon-visualisation/pom.xml
@@ -184,7 +184,7 @@
org.jetbrains
annotations
- 23.1.0
+ 24.0.0
compile
From 4cc1cab77431e4bdd03cda838efa043f27d8eef2 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 12 Jan 2023 14:23:16 +0100
Subject: [PATCH 04/45] chore(deps): update dependency
org.apache.maven.plugins:maven-checkstyle-plugin to v3.2.1 (#5073)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
pom.xml | 2 +-
spoon-control-flow/pom.xml | 2 +-
spoon-decompiler/pom.xml | 2 +-
spoon-smpl/pom.xml | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 4bffe291d97..613c2462a94 100644
--- a/pom.xml
+++ b/pom.xml
@@ -256,7 +256,7 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- 3.2.0
+ 3.2.1
true
true
diff --git a/spoon-control-flow/pom.xml b/spoon-control-flow/pom.xml
index 9ffed9f44b2..a681898400c 100644
--- a/spoon-control-flow/pom.xml
+++ b/spoon-control-flow/pom.xml
@@ -27,7 +27,7 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- 3.2.0
+ 3.2.1
true
../checkstyle.xml
diff --git a/spoon-decompiler/pom.xml b/spoon-decompiler/pom.xml
index d147d3f5009..3bc931c2a99 100644
--- a/spoon-decompiler/pom.xml
+++ b/spoon-decompiler/pom.xml
@@ -82,7 +82,7 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- 3.2.0
+ 3.2.1
true
../checkstyle.xml
diff --git a/spoon-smpl/pom.xml b/spoon-smpl/pom.xml
index 886b7d756df..649d88541fd 100644
--- a/spoon-smpl/pom.xml
+++ b/spoon-smpl/pom.xml
@@ -36,7 +36,7 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- 3.2.0
+ 3.2.1
true
../checkstyle.xml
From 1a15a9d3ee646a46a071687caac4e1a8b20502e1 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 13 Jan 2023 10:29:35 +0100
Subject: [PATCH 05/45] chore(deps): update actions/setup-python action to
v4.5.0 (#5078)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
.github/workflows/tests.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index e501604fe58..fb5c6711434 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -120,7 +120,7 @@ jobs:
with:
java-version: 11
distribution: ${{ env.JAVA_DISTRIBUTION }}
- - uses: actions/setup-python@5ccb29d8773c3f3f653e1705f474dfaa8a06a912 # v4.4.0
+ - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0
with:
python-version: 3.11
From 6b69066ef3217a00a4fee41a285d0bbbb1288b65 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 13 Jan 2023 11:44:40 +0100
Subject: [PATCH 06/45] chore(deps): update github/codeql-action digest to
515828d (#5077)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
.github/workflows/qodana.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml
index cc6e0e04a7b..34c1069dd38 100644
--- a/.github/workflows/qodana.yml
+++ b/.github/workflows/qodana.yml
@@ -21,6 +21,6 @@ jobs:
uses: JetBrains/qodana-action@3fdeefa830a7634a5c04f1cd70fcfb69956137a2 # v2022.3.0
with:
args: --source-directory,./src/main/java , --fail-threshold, 0
- - uses: github/codeql-action/upload-sarif@959cbb7472c4d4ad70cdfe6f4976053fe48ab394 # v2
+ - uses: github/codeql-action/upload-sarif@515828d97454b8354517688ddc5b48402b723750 # v2
with:
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
From 2013b693b04f3c7acac3ad6ba2ed42512e925bd0 Mon Sep 17 00:00:00 2001
From: I-Al-Istannen
Date: Mon, 16 Jan 2023 20:59:18 +0100
Subject: [PATCH 07/45] fix: Reject invalid float/double literals (#5071)
---
.../spoon/reflect/visitor/LiteralHelper.java | 9 ++++++++-
.../support/reflect/code/CtLiteralImpl.java | 4 ++--
.../visitor/DefaultJavaPrettyPrinterTest.java | 16 ++++++++++++++++
3 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/main/java/spoon/reflect/visitor/LiteralHelper.java b/src/main/java/spoon/reflect/visitor/LiteralHelper.java
index 103893c2d45..74dbf844752 100644
--- a/src/main/java/spoon/reflect/visitor/LiteralHelper.java
+++ b/src/main/java/spoon/reflect/visitor/LiteralHelper.java
@@ -7,6 +7,7 @@
*/
package spoon.reflect.visitor;
+import spoon.SpoonException;
import spoon.reflect.code.CtLiteral;
import spoon.reflect.code.CtTextBlock;
import spoon.reflect.code.LiteralBase;
@@ -43,13 +44,19 @@ private static String getBasedString(Long value, LiteralBase base) {
}
private static String getBasedString(Float value, LiteralBase base) {
+ if (value.isInfinite() || value.isNaN()) {
+ throw new SpoonException("Can not convert " + value + " to a float literal.");
+ }
if (base == LiteralBase.HEXADECIMAL) {
return Float.toHexString(value) + "F";
}
- return Float.toString(value) + "F";
+ return value + "F";
}
private static String getBasedString(Double value, LiteralBase base) {
+ if (value.isInfinite() || value.isNaN()) {
+ throw new SpoonException("Can not convert " + value + " to a double literal.");
+ }
if (base == LiteralBase.HEXADECIMAL) {
return Double.toHexString(value);
}
diff --git a/src/main/java/spoon/support/reflect/code/CtLiteralImpl.java b/src/main/java/spoon/support/reflect/code/CtLiteralImpl.java
index fde6192b909..0a9450228d7 100644
--- a/src/main/java/spoon/support/reflect/code/CtLiteralImpl.java
+++ b/src/main/java/spoon/support/reflect/code/CtLiteralImpl.java
@@ -38,8 +38,8 @@ public T getValue() {
@Override
public > C setValue(T value) {
- if (this.value instanceof CtElement) {
- ((CtElement) this.value).setParent(this);
+ if (value instanceof CtElement) {
+ ((CtElement) value).setParent(this);
}
getFactory().getEnvironment().getModelChangeListener().onObjectUpdate(this, EXPRESSION, value, this.value);
this.value = value;
diff --git a/src/test/java/spoon/reflect/visitor/DefaultJavaPrettyPrinterTest.java b/src/test/java/spoon/reflect/visitor/DefaultJavaPrettyPrinterTest.java
index 84ff94fe4ba..039ef7e30b3 100644
--- a/src/test/java/spoon/reflect/visitor/DefaultJavaPrettyPrinterTest.java
+++ b/src/test/java/spoon/reflect/visitor/DefaultJavaPrettyPrinterTest.java
@@ -10,6 +10,7 @@
import org.junit.jupiter.params.provider.ArgumentsSource;
import org.junit.jupiter.params.provider.ValueSource;
import spoon.Launcher;
+import spoon.SpoonException;
import spoon.SpoonModelBuilder;
import spoon.compiler.SpoonResourceHelper;
import spoon.reflect.CtModel;
@@ -47,6 +48,7 @@
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static spoon.test.SpoonTestHelpers.containsRegexMatch;
public class DefaultJavaPrettyPrinterTest {
@@ -376,4 +378,18 @@ void bracketsShouldBeMinimallyPrintedOnShadowedFields() throws FileNotFoundExcep
CtLocalVariable localVariable = model.getElements(new TypeFilter<>(CtLocalVariable.class)).get(1);
assertThat(localVariable.toString(), equalTo("int fieldReadOfA = ((A) c).a.i"));
}
+
+ @ParameterizedTest(name = "Printing literal ''{0}'' throws an error")
+ @ValueSource(doubles = {
+ Double.NEGATIVE_INFINITY,
+ Double.POSITIVE_INFINITY,
+ Double.NaN
+ })
+ void throwsExceptionWhenPrintingInvalidFloatingLiteral(double value) {
+ // contract: Printing invalid floating literals throws an exception
+ Factory factory = new Launcher().getFactory();
+
+ assertThrows(SpoonException.class, () -> factory.createLiteral(value).toString());
+ assertThrows(SpoonException.class, () -> factory.createLiteral((float) value).toString());
+ }
}
From 914b1132f7f93b17ebcb6075c872a8c595cf4778 Mon Sep 17 00:00:00 2001
From: Daniel Bobbert
Date: Thu, 19 Jan 2023 08:27:25 +0100
Subject: [PATCH 08/45] feat: read parameter names from bytecode if possible
(#4972)
Co-authored-by: I-Al-Istannen
---
.../support/visitor/java/reflect/RtParameter.java | 15 +++++++++++++--
.../java/JavaReflectionTreeBuilderTest.java | 2 +-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/main/java/spoon/support/visitor/java/reflect/RtParameter.java b/src/main/java/spoon/support/visitor/java/reflect/RtParameter.java
index 6fcdd4ced89..8847aa29168 100644
--- a/src/main/java/spoon/support/visitor/java/reflect/RtParameter.java
+++ b/src/main/java/spoon/support/visitor/java/reflect/RtParameter.java
@@ -11,6 +11,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Parameter;
import java.lang.reflect.Type;
/**
@@ -143,7 +144,12 @@ public int hashCode() {
public static RtParameter[] parametersOf(RtMethod method) {
RtParameter[] parameters = new RtParameter[method.getParameterTypes().length];
for (int index = 0; index < method.getParameterTypes().length; index++) {
- parameters[index] = new RtParameter(null, method.getParameterTypes()[index], method.getGenericParameterTypes()[index], method, null, index);
+ String name = null;
+ Parameter parameter = method.getMethod().getParameters()[index];
+ if (parameter.isNamePresent()) {
+ name = parameter.getName();
+ }
+ parameters[index] = new RtParameter(name, method.getParameterTypes()[index], method.getGenericParameterTypes()[index], method, null, index);
}
return parameters;
}
@@ -179,7 +185,12 @@ public static RtParameter[] parametersOf(Constructor constructor) {
}
for (int index = 0; index < constructor.getGenericParameterTypes().length; index++) {
- parameters[index] = new RtParameter(null, constructor.getParameterTypes()[index + offset], constructor.getGenericParameterTypes()[index], null, constructor, index);
+ String name = null;
+ Parameter parameter = constructor.getParameters()[index + offset];
+ if (parameter.isNamePresent()) {
+ name = parameter.getName();
+ }
+ parameters[index] = new RtParameter(name, constructor.getParameterTypes()[index + offset], constructor.getGenericParameterTypes()[index], null, constructor, index);
}
return parameters;
}
diff --git a/src/test/java/spoon/support/visitor/java/JavaReflectionTreeBuilderTest.java b/src/test/java/spoon/support/visitor/java/JavaReflectionTreeBuilderTest.java
index aa0236322a8..2406e2ef6d3 100644
--- a/src/test/java/spoon/support/visitor/java/JavaReflectionTreeBuilderTest.java
+++ b/src/test/java/spoon/support/visitor/java/JavaReflectionTreeBuilderTest.java
@@ -847,7 +847,7 @@ void testInnerClassesConstructorParameters() {
assertThat(asClass.getConstructors().iterator().next().getParameters().size(), equalTo(inners.size()));
}
- @GitHubIssue(issueNumber = 4972, fixed = false)
+ @GitHubIssue(issueNumber = 4972, fixed = true)
void parameterNamesAreParsedWhenCompilingWithParametersFlag() throws ClassNotFoundException {
ClassLoader loader = JavacFacade.compileFiles(
Map.of(
From c4925924d839bb82d9f97cbea6f4ed91d5ee7e54 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 26 Jan 2023 21:16:23 +0100
Subject: [PATCH 09/45] chore(deps): update mockito monorepo to v5 (#5079)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
spoon-pom/pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/spoon-pom/pom.xml b/spoon-pom/pom.xml
index be137e98988..87cbb1d2612 100644
--- a/spoon-pom/pom.xml
+++ b/spoon-pom/pom.xml
@@ -32,7 +32,7 @@
org.mockito
mockito-core
- 4.11.0
+ 5.0.0
test
@@ -56,7 +56,7 @@
org.mockito
mockito-junit-jupiter
- 4.11.0
+ 5.0.0
test
From e7d9c33ba8f659798ed6e4e9f5de30915820a105 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 26 Jan 2023 21:17:02 +0100
Subject: [PATCH 10/45] chore(deps): update dependency
se.kth.castor:depclean-maven-plugin to v2.0.6 (#5080)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
spoon-pom/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/spoon-pom/pom.xml b/spoon-pom/pom.xml
index 87cbb1d2612..b85b66ea266 100644
--- a/spoon-pom/pom.xml
+++ b/spoon-pom/pom.xml
@@ -208,7 +208,7 @@
se.kth.castor
depclean-maven-plugin
- 2.0.5
+ 2.0.6
From f4708ca6adf3afb6e5dc00b1a9a2621a78555c32 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Wed, 1 Feb 2023 17:22:25 +0100
Subject: [PATCH 11/45] chore(deps): update dependency
org.apache.maven.plugins:maven-surefire-plugin to v3.0.0-m8 (#5075)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
spoon-pom/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/spoon-pom/pom.xml b/spoon-pom/pom.xml
index b85b66ea266..fee9b8bd19a 100644
--- a/spoon-pom/pom.xml
+++ b/spoon-pom/pom.xml
@@ -276,7 +276,7 @@
maven-surefire-plugin
- 3.0.0-M7
+ 3.0.0-M8
From 578bd8f5abbf095bf456f3c64ed8a9d520aff53b Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 3 Feb 2023 13:13:58 +0100
Subject: [PATCH 19/45] chore(deps): update plugin
com.github.ben-manes.versions to v0.45.0 (#5095)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
spoon-dataflow/build.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/spoon-dataflow/build.gradle b/spoon-dataflow/build.gradle
index 4c955b25e08..199d625d52d 100644
--- a/spoon-dataflow/build.gradle
+++ b/spoon-dataflow/build.gradle
@@ -5,7 +5,7 @@ plugins {
// always depends on the latest snapshot of Spoon
// https://github.com/patrikerdes/gradle-use-latest-versions-plugin
id 'se.patrikerdes.use-latest-versions' version '0.2.18'
- id 'com.github.ben-manes.versions' version '0.44.0'
+ id 'com.github.ben-manes.versions' version '0.45.0'
id "com.github.johnrengelman.shadow" version "7.1.2"
}
From 3478be89f111cd45b544cb7060bea590b84d6e8e Mon Sep 17 00:00:00 2001
From: I-Al-Istannen
Date: Sat, 4 Feb 2023 21:05:40 +0100
Subject: [PATCH 20/45] fix: enclosing class parameters being ignored for
static inner classes (#5096)
---
.../java/JavaReflectionVisitorImpl.java | 8 ++-
.../java/JavaReflectionTreeBuilderTest.java | 51 +++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/src/main/java/spoon/support/visitor/java/JavaReflectionVisitorImpl.java b/src/main/java/spoon/support/visitor/java/JavaReflectionVisitorImpl.java
index 023793d8159..bdf54d01659 100644
--- a/src/main/java/spoon/support/visitor/java/JavaReflectionVisitorImpl.java
+++ b/src/main/java/spoon/support/visitor/java/JavaReflectionVisitorImpl.java
@@ -339,7 +339,13 @@ private boolean isImplicitParameter(Parameter parameter, Constructor> construc
if (parameter.isImplicit()) {
return true;
}
- // best effort fallback
+ // best effort fallback for the implicit enclosing class parameter in non-static inner class constructors
+
+ // static inner classes have no implicit parameter
+ if (Modifier.isStatic(constructor.getDeclaringClass().getModifiers())) {
+ return false;
+ }
+
return isFirstParameter && parameter.getType() == constructor.getDeclaringClass().getEnclosingClass();
}
diff --git a/src/test/java/spoon/support/visitor/java/JavaReflectionTreeBuilderTest.java b/src/test/java/spoon/support/visitor/java/JavaReflectionTreeBuilderTest.java
index 2406e2ef6d3..4d1553933a9 100644
--- a/src/test/java/spoon/support/visitor/java/JavaReflectionTreeBuilderTest.java
+++ b/src/test/java/spoon/support/visitor/java/JavaReflectionTreeBuilderTest.java
@@ -23,6 +23,7 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -865,4 +866,54 @@ void parameterNamesAreParsedWhenCompilingWithParametersFlag() throws ClassNotFou
assertThat(parameter.getSimpleName(), is("bar"));
}
+ @Test
+ void testStaticInnerClassConstructorWithEnclosingClassArgument() throws ClassNotFoundException {
+ // contract: Static inner classes can take explicit arguments of the enclosing type
+ ClassLoader loader = JavacFacade.compileFiles(
+ Map.of(
+ "Outer",
+ "class Outer {\n"
+ + " static class Inner { public Inner(Outer outer) {} } \n" +
+ "}\n"
+ ),
+ List.of()
+ );
+ Class> inner = loader.loadClass("Outer$Inner");
+ CtClass> ctInner = (CtClass>) new JavaReflectionTreeBuilder(createFactory()).scan(inner);
+
+ assertEquals(1, inner.getConstructors().length);
+ assertEquals(1, inner.getConstructors()[0].getParameterCount());
+
+ assertThat(ctInner.getConstructors(), hasSize(1));
+ assertThat(
+ ctInner.getConstructors().iterator().next().getParameters(),
+ hasSize(1)
+ );
+ }
+
+ @Test
+ void testNonStaticInnerClassConstructorWithEnclosingClassArgument() throws ClassNotFoundException {
+ // contract: Non-static inner classes have one implicit argument of the enclosing type
+ ClassLoader loader = JavacFacade.compileFiles(
+ Map.of(
+ "Outer",
+ "class Outer {\n"
+ + " class Inner { public Inner(Outer outer) {} } \n" +
+ "}\n"
+ ),
+ List.of()
+ );
+ Class> inner = loader.loadClass("Outer$Inner");
+ CtClass> ctInner = (CtClass>) new JavaReflectionTreeBuilder(createFactory()).scan(inner);
+
+ assertEquals(1, inner.getConstructors().length);
+ assertEquals(2, inner.getConstructors()[0].getParameterCount());
+
+ assertThat(ctInner.getConstructors(), hasSize(1));
+ assertThat(
+ ctInner.getConstructors().iterator().next().getParameters(),
+ hasSize(1)
+ );
+ }
+
}
From a2ced94566e0be6fc869ec514add8fb7e662799b Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Wed, 8 Feb 2023 14:05:31 +0100
Subject: [PATCH 21/45] chore(deps): update github/codeql-action digest to
39d8d7e (#5097)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
.github/workflows/qodana.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml
index 411e47c12c7..f9e92080aef 100644
--- a/.github/workflows/qodana.yml
+++ b/.github/workflows/qodana.yml
@@ -21,6 +21,6 @@ jobs:
uses: JetBrains/qodana-action@c25ee7dc4d0697b27ac54877a4ff71cf5b6dde3c # v2022.3.2
with:
args: --source-directory,./src/main/java , --fail-threshold, 0
- - uses: github/codeql-action/upload-sarif@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2
+ - uses: github/codeql-action/upload-sarif@39d8d7e78f59cf6b40ac3b9fbebef0c753d7c9e5 # v2
with:
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
From 15a34859c3141c90a091af05233d61e9df98886c Mon Sep 17 00:00:00 2001
From: I-Al-Istannen
Date: Wed, 8 Feb 2023 14:08:49 +0100
Subject: [PATCH 22/45] fix: getActualClass() for multi-dimensional arrays
(#5093)
---
.../spoon/reflect/factory/TypeFactory.java | 3 ++
.../reference/CtTypeReferenceImpl.java | 17 +++++---
.../reference/CtTypeReferenceTest.java | 39 +++++++++++++++++--
3 files changed, 50 insertions(+), 9 deletions(-)
diff --git a/src/main/java/spoon/reflect/factory/TypeFactory.java b/src/main/java/spoon/reflect/factory/TypeFactory.java
index 404802ea220..d021845f578 100644
--- a/src/main/java/spoon/reflect/factory/TypeFactory.java
+++ b/src/main/java/spoon/reflect/factory/TypeFactory.java
@@ -290,6 +290,9 @@ public CtArrayTypeReference createArrayReference(CtTypeReference ref
*/
public CtArrayTypeReference> createArrayReference(CtTypeReference> reference, int n) {
CtTypeReference> componentType;
+ if (n < 1) {
+ throw new SpoonException("Array dimension must be >= 1");
+ }
if (n == 1) {
return createArrayReference(reference);
}
diff --git a/src/main/java/spoon/support/reflect/reference/CtTypeReferenceImpl.java b/src/main/java/spoon/support/reflect/reference/CtTypeReferenceImpl.java
index e0c3c752aa7..6b25fe3c630 100644
--- a/src/main/java/spoon/support/reflect/reference/CtTypeReferenceImpl.java
+++ b/src/main/java/spoon/support/reflect/reference/CtTypeReferenceImpl.java
@@ -45,6 +45,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+
import static spoon.reflect.ModelElementContainerDefaultCapacities.TYPE_TYPE_PARAMETERS_CONTAINER_DEFAULT_CAPACITY;
import static spoon.reflect.path.CtRole.DECLARING_TYPE;
import static spoon.reflect.path.CtRole.IS_SHADOW;
@@ -156,12 +157,14 @@ protected Class findClass() {
if (isArray()) {
CtTypeReference> componentTypeReference = convertToComponentType();
if (componentTypeReference.isPrimitive()) {
- return getPrimitiveType(componentTypeReference).map(this::arrayType).orElseThrow(() -> new SpoonException("Cant find primitive type: " + componentTypeReference));
+ return getPrimitiveType(componentTypeReference)
+ .map(this::asArrayTypeWithOurDimensions)
+ .orElseThrow(() -> new SpoonException("Cant find primitive type: " + componentTypeReference));
}
typeReference = componentTypeReference;
}
Class actualClass = getClassFromThreadLocalCacheOrLoad(typeReference);
- return isArray() ? arrayType(actualClass) : actualClass;
+ return isArray() ? asArrayTypeWithOurDimensions(actualClass) : actualClass;
}
@SuppressWarnings("unchecked")
@@ -177,7 +180,7 @@ private Class getClassFromThreadLocalCacheOrLoad(CtTypeReference> typeRefer
* @return the component type of the type reference.
*/
private CtTypeReference convertToComponentType() {
- if (this.getQualifiedName().indexOf("[") == -1) {
+ if (!this.getQualifiedName().contains("[")) {
return this;
}
return getFactory().createReference(this.getQualifiedName().substring(0, this.getQualifiedName().indexOf("[")));
@@ -210,9 +213,13 @@ private void checkCacheIntegrity(ClassLoader classLoader) {
* @return the array type.
*/
@SuppressWarnings("unchecked")
- private Class arrayType(Class clazz) {
- return (Class) Array.newInstance(clazz, 0).getClass();
+ private Class asArrayTypeWithOurDimensions(Class clazz) {
+ String simpleName = getSimpleName();
+ int dimensionCount = (simpleName.length() - simpleName.indexOf('[')) / 2;
+ int[] dimensions = new int[dimensionCount];
+ return (Class) Array.newInstance(clazz, dimensions).getClass();
}
+
@Override
public List> getActualTypeArguments() {
return actualTypeArguments;
diff --git a/src/test/java/spoon/reflect/reference/CtTypeReferenceTest.java b/src/test/java/spoon/reflect/reference/CtTypeReferenceTest.java
index f10703bf674..28be8d62ae8 100644
--- a/src/test/java/spoon/reflect/reference/CtTypeReferenceTest.java
+++ b/src/test/java/spoon/reflect/reference/CtTypeReferenceTest.java
@@ -3,10 +3,13 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.Mock;
import org.mockito.stubbing.Answer;
+import spoon.Launcher;
import spoon.compiler.Environment;
import spoon.reflect.factory.Factory;
import spoon.reflect.factory.TypeFactory;
@@ -32,9 +35,9 @@ public class CtTypeReferenceTest {
@Mock private ClassLoader classLoader;
@BeforeEach public void setUp() {
- when(factory.Type()).thenReturn(typeFactory);
- when(factory.getEnvironment()).thenReturn(environment);
- when(environment.getModelChangeListener()).thenReturn(listener);
+ Mockito.lenient().when(factory.Type()).thenReturn(typeFactory);
+ Mockito.lenient().when(factory.getEnvironment()).thenReturn(environment);
+ Mockito.lenient().when(environment.getModelChangeListener()).thenReturn(listener);
Mockito.lenient().when(environment.getInputClassLoader()).thenReturn(classLoader);
}
@@ -90,4 +93,32 @@ private void testBoxingFunction(Supplier extends CtTypeReference>> supplier,
//contract: box/unbox returns a reference toward the expected type
assertEquals(expectedClass.getName(), result.getQualifiedName());
}
-}
\ No newline at end of file
+
+ @ParameterizedTest
+ @CsvSource(value = {
+ "byte, 2, byte[][]",
+ "byte, 3, byte[][][]",
+ "java.lang.String, 3, String[][][]",
+ "char, 1, char[]",
+ "boolean, 1, boolean[]",
+ "byte, 1, byte[]",
+ "short, 1, short[]",
+ "int, 1, int[]",
+ "long, 1, long[]",
+ "float, 1, float[]",
+ "double, 1, double[]",
+ })
+ void testGetActualClassForArray(String className, int arrayDepth, String expected) {
+ // contract: "getActualClass" should return proper classes for multi-dimensional arrays
+ Factory factory = new Launcher().getFactory();
+ CtArrayTypeReference> reference = factory.createArrayReference(
+ factory.createReference(className),
+ arrayDepth
+ );
+ assertEquals(
+ expected,
+ reference.getActualClass().getSimpleName()
+ );
+ }
+
+}
From 1b7c3da793b3b5814eba8b99ce84501ace4a29b5 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Wed, 8 Feb 2023 17:41:32 +0100
Subject: [PATCH 23/45] chore(deps): update jetbrains/qodana-action action to
v2022.3.3 (#5101)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
.github/workflows/qodana.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml
index f9e92080aef..61bda14c800 100644
--- a/.github/workflows/qodana.yml
+++ b/.github/workflows/qodana.yml
@@ -18,7 +18,7 @@ jobs:
with:
fetch-depth: 0
- name: 'Qodana Scan'
- uses: JetBrains/qodana-action@c25ee7dc4d0697b27ac54877a4ff71cf5b6dde3c # v2022.3.2
+ uses: JetBrains/qodana-action@584b706efdfc1149cfb5234066b3bbf73d48249e # v2022.3.3
with:
args: --source-directory,./src/main/java , --fail-threshold, 0
- uses: github/codeql-action/upload-sarif@39d8d7e78f59cf6b40ac3b9fbebef0c753d7c9e5 # v2
From 9cba61fbafe5f8c099a3ca784a9f80813a2f52f5 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Wed, 8 Feb 2023 17:42:10 +0100
Subject: [PATCH 24/45] chore(deps): update actions/setup-java action to
v3.10.0 (#5099)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
.github/workflows/sbom.yml | 2 +-
.github/workflows/tests.yml | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/sbom.yml b/.github/workflows/sbom.yml
index 4fbd560e906..202f05b1c04 100644
--- a/.github/workflows/sbom.yml
+++ b/.github/workflows/sbom.yml
@@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 0
- - uses: actions/setup-java@1df8dbefe2a8cbc99770194893dd902763bee34b # v3.9.0
+ - uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98 # v3.10.0
with:
java-version: 17
distribution: ${{ env.JAVA_DISTRIBUTION }}
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 63dfc37754e..c00f74aa41b 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -43,7 +43,7 @@ jobs:
- name: Disable Git's autocrlf
run: git config --global core.autocrlf false
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- - uses: actions/setup-java@1df8dbefe2a8cbc99770194893dd902763bee34b # v3.9.0
+ - uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98 # v3.10.0
with:
java-version: ${{ matrix.java }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
@@ -80,7 +80,7 @@ jobs:
name: Test with coverage
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- - uses: actions/setup-java@1df8dbefe2a8cbc99770194893dd902763bee34b # v3.9.0
+ - uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98 # v3.10.0
with:
java-version: 17
distribution: ${{ env.JAVA_DISTRIBUTION }}
@@ -116,7 +116,7 @@ jobs:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 0
- - uses: actions/setup-java@1df8dbefe2a8cbc99770194893dd902763bee34b # v3.9.0
+ - uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98 # v3.10.0
with:
java-version: 11
distribution: ${{ env.JAVA_DISTRIBUTION }}
@@ -150,7 +150,7 @@ jobs:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 0
- - uses: actions/setup-java@1df8dbefe2a8cbc99770194893dd902763bee34b # v3.9.0
+ - uses: actions/setup-java@3f07048e3d294f56e9b90ac5ea2c6f74e9ad0f98 # v3.10.0
with:
java-version: 17
distribution: ${{ env.JAVA_DISTRIBUTION }}
From 5ad3c5769101530f8f906975f2e29baebfc1638e Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 16 Feb 2023 21:35:09 +0100
Subject: [PATCH 25/45] chore(deps): update dependency
org.apache.maven.plugins:maven-javadoc-plugin to v3.5.0 (#5112)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
spoon-pom/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/spoon-pom/pom.xml b/spoon-pom/pom.xml
index 0a890645e85..cf7fa7bf9c4 100644
--- a/spoon-pom/pom.xml
+++ b/spoon-pom/pom.xml
@@ -256,7 +256,7 @@
maven-javadoc-plugin
- 3.4.1
+ 3.5.0
maven-project-info-reports-plugin
From fd664dfede1f56b2df5c4e197d914af53af8c3d6 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 16 Feb 2023 21:35:46 +0100
Subject: [PATCH 26/45] chore(deps): update jetbrains/qodana-action action to
v2022.3.4 (#5111)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
.github/workflows/qodana.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml
index 61bda14c800..bbe4f9d3c93 100644
--- a/.github/workflows/qodana.yml
+++ b/.github/workflows/qodana.yml
@@ -18,7 +18,7 @@ jobs:
with:
fetch-depth: 0
- name: 'Qodana Scan'
- uses: JetBrains/qodana-action@584b706efdfc1149cfb5234066b3bbf73d48249e # v2022.3.3
+ uses: JetBrains/qodana-action@7afb26c0c2f325c0d5c21ea1f617c79c7f899337 # v2022.3.4
with:
args: --source-directory,./src/main/java , --fail-threshold, 0
- uses: github/codeql-action/upload-sarif@39d8d7e78f59cf6b40ac3b9fbebef0c753d7c9e5 # v2
From 07b72c8b084c7b0ff7bc9ef4760a23ee1f0f96ac Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 16 Feb 2023 21:37:26 +0100
Subject: [PATCH 27/45] chore(deps): update dependency
org.apache.maven.plugins:maven-surefire-plugin to v3.0.0-m9 (#5109)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
spoon-pom/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/spoon-pom/pom.xml b/spoon-pom/pom.xml
index cf7fa7bf9c4..857976d5e71 100644
--- a/spoon-pom/pom.xml
+++ b/spoon-pom/pom.xml
@@ -276,7 +276,7 @@
maven-surefire-plugin
- 3.0.0-M8
+ 3.0.0-M9