projects/guix·blob java-team · refs

298 lines · 16.1 KiB

1This patch fixes build issues caused by the java compiler not finding the
2correct types on some statements.
3
4From 10ce6e0e30bbaf22212abc77f5d644c074df6068 Mon Sep 17 00:00:00 2001
5From: Julien Lepiller <[email protected]>
6Date: Sat, 25 Feb 2023 18:00:13 +0100
7Subject: [PATCH] Fix java files.
8
9---
10 .../ConditionalStateStackManipulation.java | 6 ++--
11 .../org/powermock/core/bytebuddy/Frame.java | 2 +-
12 .../core/bytebuddy/MaxLocalsExtractor.java | 6 ++--
13 .../core/bytebuddy/MockGetawayCall.java | 2 +-
14 .../core/bytebuddy/PrimitiveBoxing.java | 4 +--
15 .../agent/DefinalizingClassTransformer.java | 4 +--
16 .../agent/DefinalizingClassVisitor.java | 6 ++--
17 .../impl/DelegatingPowerMockRunner.java | 13 +++++---
18 .../org/powermock/reflect/WhiteBoxTest.java | 32 +++++++++----------
19 .../reflect/internal/proxy/ClassFactory.java | 6 ++--
20 10 files changed, 43 insertions(+), 38 deletions(-)
21
22diff --git a/powermock-core/src/main/java/org/powermock/core/bytebuddy/ConditionalStateStackManipulation.java b/powermock-core/src/main/java/org/powermock/core/bytebuddy/ConditionalStateStackManipulation.java
23index fa23a3f..1fa4b94 100644
24--- a/powermock-core/src/main/java/org/powermock/core/bytebuddy/ConditionalStateStackManipulation.java
25+++ b/powermock-core/src/main/java/org/powermock/core/bytebuddy/ConditionalStateStackManipulation.java
26@@ -20,9 +20,9 @@ package org.powermock.core.bytebuddy;
27
28 import net.bytebuddy.implementation.Implementation.Context;
29 import net.bytebuddy.implementation.bytecode.StackManipulation;
30-import net.bytebuddy.jar.asm.Label;
31-import net.bytebuddy.jar.asm.MethodVisitor;
32-import net.bytebuddy.jar.asm.Opcodes;
33+import org.objectweb.asm.Label;
34+import org.objectweb.asm.MethodVisitor;
35+import org.objectweb.asm.Opcodes;
36
37 public class ConditionalStateStackManipulation implements StackManipulation {
38
39diff --git a/powermock-core/src/main/java/org/powermock/core/bytebuddy/Frame.java b/powermock-core/src/main/java/org/powermock/core/bytebuddy/Frame.java
40index 8ada262..adfc218 100644
41--- a/powermock-core/src/main/java/org/powermock/core/bytebuddy/Frame.java
42+++ b/powermock-core/src/main/java/org/powermock/core/bytebuddy/Frame.java
43@@ -24,7 +24,7 @@ import net.bytebuddy.description.method.ParameterDescription.InDefinedShape;
44 import net.bytebuddy.description.method.ParameterList;
45 import net.bytebuddy.description.type.TypeDescription.Generic;
46 import net.bytebuddy.implementation.bytecode.StackSize;
47-import net.bytebuddy.jar.asm.Opcodes;
48+import org.objectweb.asm.Opcodes;
49 import net.bytebuddy.utility.CompoundList;
50
51 import java.util.ArrayList;
52diff --git a/powermock-core/src/main/java/org/powermock/core/bytebuddy/MaxLocalsExtractor.java b/powermock-core/src/main/java/org/powermock/core/bytebuddy/MaxLocalsExtractor.java
53index 6b5cddd..8fe1936 100644
54--- a/powermock-core/src/main/java/org/powermock/core/bytebuddy/MaxLocalsExtractor.java
55+++ b/powermock-core/src/main/java/org/powermock/core/bytebuddy/MaxLocalsExtractor.java
56@@ -19,9 +19,9 @@
57 package org.powermock.core.bytebuddy;
58
59 import net.bytebuddy.description.method.MethodDescription;
60-import net.bytebuddy.jar.asm.ClassVisitor;
61-import net.bytebuddy.jar.asm.MethodVisitor;
62-import net.bytebuddy.jar.asm.Opcodes;
63+import org.objectweb.asm.ClassVisitor;
64+import org.objectweb.asm.MethodVisitor;
65+import org.objectweb.asm.Opcodes;
66
67 public class MaxLocalsExtractor extends ClassVisitor {
68
69diff --git a/powermock-core/src/main/java/org/powermock/core/bytebuddy/MockGetawayCall.java b/powermock-core/src/main/java/org/powermock/core/bytebuddy/MockGetawayCall.java
70index db84196..84942f8 100644
71--- a/powermock-core/src/main/java/org/powermock/core/bytebuddy/MockGetawayCall.java
72+++ b/powermock-core/src/main/java/org/powermock/core/bytebuddy/MockGetawayCall.java
73@@ -27,7 +27,7 @@ import net.bytebuddy.implementation.bytecode.StackManipulation;
74 import net.bytebuddy.implementation.bytecode.collection.ArrayFactory;
75 import net.bytebuddy.implementation.bytecode.constant.ClassConstant;
76 import net.bytebuddy.implementation.bytecode.member.MethodInvocation;
77-import net.bytebuddy.jar.asm.MethodVisitor;
78+import org.objectweb.asm.MethodVisitor;
79 import org.powermock.core.bytebuddy.Variable.VariableAccess;
80 import org.powermock.reflect.internal.WhiteboxImpl;
81
82diff --git a/powermock-core/src/main/java/org/powermock/core/bytebuddy/PrimitiveBoxing.java b/powermock-core/src/main/java/org/powermock/core/bytebuddy/PrimitiveBoxing.java
83index e200b22..ae1036b 100644
84--- a/powermock-core/src/main/java/org/powermock/core/bytebuddy/PrimitiveBoxing.java
85+++ b/powermock-core/src/main/java/org/powermock/core/bytebuddy/PrimitiveBoxing.java
86@@ -24,8 +24,8 @@ import net.bytebuddy.description.type.TypeDescription.ForLoadedType;
87 import net.bytebuddy.implementation.Implementation;
88 import net.bytebuddy.implementation.bytecode.StackManipulation;
89 import net.bytebuddy.implementation.bytecode.StackSize;
90-import net.bytebuddy.jar.asm.MethodVisitor;
91-import net.bytebuddy.jar.asm.Opcodes;
92+import org.objectweb.asm.MethodVisitor;
93+import org.objectweb.asm.Opcodes;
94
95 public enum PrimitiveBoxing implements StackManipulation{
96
97diff --git a/powermock-modules/powermock-module-javaagent/src/main/java/org/powermock/modules/agent/DefinalizingClassTransformer.java b/powermock-modules/powermock-module-javaagent/src/main/java/org/powermock/modules/agent/DefinalizingClassTransformer.java
98index e8eef7a..01d0bcb 100644
99--- a/powermock-modules/powermock-module-javaagent/src/main/java/org/powermock/modules/agent/DefinalizingClassTransformer.java
100+++ b/powermock-modules/powermock-module-javaagent/src/main/java/org/powermock/modules/agent/DefinalizingClassTransformer.java
101@@ -16,8 +16,8 @@
102
103 package org.powermock.modules.agent;
104
105-import net.bytebuddy.jar.asm.ClassReader;
106-import net.bytebuddy.jar.asm.ClassWriter;
107+import org.objectweb.asm.ClassReader;
108+import org.objectweb.asm.ClassWriter;
109
110 import java.lang.instrument.ClassFileTransformer;
111 import java.security.ProtectionDomain;
112diff --git a/powermock-modules/powermock-module-javaagent/src/main/java/org/powermock/modules/agent/DefinalizingClassVisitor.java b/powermock-modules/powermock-module-javaagent/src/main/java/org/powermock/modules/agent/DefinalizingClassVisitor.java
113index 3bb80c3..9aada60 100644
114--- a/powermock-modules/powermock-module-javaagent/src/main/java/org/powermock/modules/agent/DefinalizingClassVisitor.java
115+++ b/powermock-modules/powermock-module-javaagent/src/main/java/org/powermock/modules/agent/DefinalizingClassVisitor.java
116@@ -1,8 +1,8 @@
117 package org.powermock.modules.agent;
118
119-import net.bytebuddy.jar.asm.ClassVisitor;
120-import net.bytebuddy.jar.asm.MethodVisitor;
121-import net.bytebuddy.jar.asm.Opcodes;
122+import org.objectweb.asm.ClassVisitor;
123+import org.objectweb.asm.MethodVisitor;
124+import org.objectweb.asm.Opcodes;
125
126 class DefinalizingClassVisitor extends ClassVisitor {
127
128diff --git a/powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/internal/impl/DelegatingPowerMockRunner.java b/powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/internal/impl/DelegatingPowerMockRunner.java
129index 301f854..caecbbd 100644
130--- a/powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/internal/impl/DelegatingPowerMockRunner.java
131+++ b/powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/internal/impl/DelegatingPowerMockRunner.java
132@@ -98,12 +98,17 @@ implements PowerMockJUnitRunnerDelegate, Filterable {
133 @Override
134 public Runner call() throws Exception {
135 try {
136- return Whitebox.invokeConstructor(
137- testClass.isAnnotationPresent(PowerMockRunnerDelegate.class)
138- ? testClass.getAnnotation(PowerMockRunnerDelegate.class).value()
139- : PowerMockRunnerDelegate.DefaultJUnitRunner.class,
140+ if(testClass.isAnnotationPresent(PowerMockRunnerDelegate.class)) {
141+ return Whitebox.invokeConstructor(
142+ testClass.getAnnotation(PowerMockRunnerDelegate.class).value(),
143 new Class[] {Class.class},
144 new Object[] {testClass});
145+ } else {
146+ return Whitebox.invokeConstructor(
147+ PowerMockRunnerDelegate.DefaultJUnitRunner.class,
148+ new Class[] {Class.class},
149+ new Object[] {testClass});
150+ }
151 } catch (ConstructorNotFoundException rootProblem) {
152 if (testClass.isAnnotationPresent(PowerMockRunnerDelegate.class)
153 && JUnitVersion.isGreaterThanOrEqualTo("4.5")) {
154diff --git a/powermock-reflect/src/test/java/org/powermock/reflect/WhiteBoxTest.java b/powermock-reflect/src/test/java/org/powermock/reflect/WhiteBoxTest.java
155index acb3154..8c24fbc 100644
156--- a/powermock-reflect/src/test/java/org/powermock/reflect/WhiteBoxTest.java
157+++ b/powermock-reflect/src/test/java/org/powermock/reflect/WhiteBoxTest.java
158@@ -248,7 +248,7 @@ public class WhiteBoxTest {
159
160 @Test
161 public void testMethodWithPrimitiveAndWrappedInt_primtive_wrapped() throws Exception {
162- assertEquals(17, Whitebox.invokeMethod(new ClassWithPrivateMethods(), "methodWithPrimitiveAndWrappedInt",
163+ assertEquals(17, (int) Whitebox.invokeMethod(new ClassWithPrivateMethods(), "methodWithPrimitiveAndWrappedInt",
164 new Class[]{int.class, Integer.class}, 9, Integer.valueOf(8)));
165 }
166
167@@ -257,13 +257,13 @@ public class WhiteBoxTest {
168 int expected = 123;
169 Whitebox.setInternalState(ClassWithInternalState.class, "staticState", expected);
170 assertEquals(expected, ClassWithInternalState.getStaticState());
171- assertEquals(expected, Whitebox.getInternalState(ClassWithInternalState.class, "staticState"));
172+ assertEquals(expected, (int) Whitebox.getInternalState(ClassWithInternalState.class, "staticState"));
173 }
174
175 @Test
176 public void testStaticFinalPrimitiveState() {
177 Whitebox.setInternalState(ClassWithInternalState.class, "staticFinalIntState", 123);
178- assertEquals(123, Whitebox.getInternalState(ClassWithInternalState.class, "staticFinalIntState"));
179+ assertEquals(123, (int) Whitebox.getInternalState(ClassWithInternalState.class, "staticFinalIntState"));
180 }
181
182 @Test
183@@ -330,25 +330,25 @@ public class WhiteBoxTest {
184 @Test
185 public void testInvokeVarArgsMethod_multipleValues() throws Exception {
186 ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
187- assertEquals(6, Whitebox.invokeMethod(tested, "varArgsMethod", 1, 2, 3));
188+ assertEquals(6, (int) Whitebox.invokeMethod(tested, "varArgsMethod", 1, 2, 3));
189 }
190
191 @Test
192 public void testInvokeVarArgsMethod_noArguments() throws Exception {
193 ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
194- assertEquals(0, Whitebox.invokeMethod(tested, "varArgsMethod"));
195+ assertEquals(0, (int) Whitebox.invokeMethod(tested, "varArgsMethod"));
196 }
197
198 @Test
199 public void testInvokeVarArgsMethod_oneArgument() throws Exception {
200 ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
201- assertEquals(4, Whitebox.invokeMethod(tested, "varArgsMethod", 2));
202+ assertEquals(4, (int) Whitebox.invokeMethod(tested, "varArgsMethod", 2));
203 }
204
205 @Test
206 public void testInvokeVarArgsMethod_invokeVarArgsWithOneArgument() throws Exception {
207 ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
208- assertEquals(1, Whitebox.invokeMethod(tested, "varArgsMethod", new Class<?>[]{int[].class}, 1));
209+ assertEquals(1, (int) Whitebox.invokeMethod(tested, "varArgsMethod", new Class<?>[]{int[].class}, 1));
210 }
211
212 @Test
213@@ -372,7 +372,7 @@ public class WhiteBoxTest {
214 ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() {
215 };
216 Whitebox.setInternalState(tested, fieldName, value);
217- assertEquals(value, Whitebox.getInternalState(tested, fieldName));
218+ assertEquals(value, (int) Whitebox.getInternalState(tested, fieldName));
219 }
220
221 @Test
222@@ -383,8 +383,8 @@ public class WhiteBoxTest {
223 ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() {
224 };
225 Whitebox.setInternalState(tested, fieldName, value);
226- assertEquals(value, Whitebox.getInternalState(tested, fieldName));
227- assertEquals(-1, Whitebox.getInternalState(tested, fieldName, ClassWithInternalState.class));
228+ assertEquals(value, (int) Whitebox.getInternalState(tested, fieldName));
229+ assertEquals(-1, (int) Whitebox.getInternalState(tested, fieldName, ClassWithInternalState.class));
230 }
231
232 @Test(expected = IllegalArgumentException.class)
233@@ -394,7 +394,7 @@ public class WhiteBoxTest {
234 ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() {
235 };
236 Whitebox.setInternalState(tested, fieldName, new Object());
237- assertEquals(value, Whitebox.getInternalState(tested, fieldName));
238+ assertEquals(value, (int) Whitebox.getInternalState(tested, fieldName));
239 }
240
241 @Test(expected = IllegalArgumentException.class)
242@@ -404,7 +404,7 @@ public class WhiteBoxTest {
243 ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState() {
244 };
245 Whitebox.setInternalState(tested, fieldName, (Object) null);
246- assertEquals(value, Whitebox.getInternalState(tested, fieldName));
247+ assertEquals(value, (int) Whitebox.getInternalState(tested, fieldName));
248 }
249
250 @Test
251@@ -413,8 +413,8 @@ public class WhiteBoxTest {
252 ClassWithChildThatHasInternalState tested = new ClassWithChildThatHasInternalState();
253 Whitebox.setInternalState(tested, int.class, value);
254 assertEquals(value, (int) Whitebox.getInternalState(tested, int.class));
255- assertEquals(value, Whitebox.getInternalState(tested, "anotherInternalState"));
256- assertEquals(value, Whitebox.getInternalState(tested, "anotherInternalState",
257+ assertEquals(value, (int) Whitebox.getInternalState(tested, "anotherInternalState"));
258+ assertEquals(value, (int) Whitebox.getInternalState(tested, "anotherInternalState",
259 ClassWithChildThatHasInternalState.class));
260 }
261
262@@ -425,7 +425,7 @@ public class WhiteBoxTest {
263 Whitebox.setInternalState(tested, int.class, value, ClassWithInternalState.class);
264 assertEquals(42, (int) Whitebox.getInternalState(tested, int.class));
265 assertEquals(value, (int) Whitebox.getInternalState(tested, int.class, ClassWithInternalState.class));
266- assertEquals(value, Whitebox.getInternalState(tested, "staticState", ClassWithInternalState.class));
267+ assertEquals(value, (int) Whitebox.getInternalState(tested, "staticState", ClassWithInternalState.class));
268 }
269
270 @Test
271@@ -621,7 +621,7 @@ public class WhiteBoxTest {
272 @Test
273 public void testInvokeMethodWithBothNormalAndVarArgsParameter() throws Exception {
274 ClassWithPrivateMethods tested = new ClassWithPrivateMethods();
275- assertEquals(4, Whitebox.invokeMethod(tested, "varArgsMethod2", 1, 2, 3));
276+ assertEquals(4, (int) Whitebox.invokeMethod(tested, "varArgsMethod2", 1, 2, 3));
277 }
278
279 @Test
280diff --git a/powermock-reflect/src/test/java/org/powermock/reflect/internal/proxy/ClassFactory.java b/powermock-reflect/src/test/java/org/powermock/reflect/internal/proxy/ClassFactory.java
281index 03db992..828bfe0 100644
282--- a/powermock-reflect/src/test/java/org/powermock/reflect/internal/proxy/ClassFactory.java
283+++ b/powermock-reflect/src/test/java/org/powermock/reflect/internal/proxy/ClassFactory.java
284@@ -1,8 +1,8 @@
285 package org.powermock.reflect.internal.proxy;
286
287-import net.bytebuddy.jar.asm.ClassWriter;
288-import net.bytebuddy.jar.asm.MethodVisitor;
289-import net.bytebuddy.jar.asm.Opcodes;
290+import org.objectweb.asm.ClassWriter;
291+import org.objectweb.asm.MethodVisitor;
292+import org.objectweb.asm.Opcodes;
293
294 class ClassFactory implements Opcodes {
295
296--
2972.38.1
298