Skip to content

Commit 95fd9d2

Browse files
author
Alex Menkov
committedFeb 7, 2022
8281243: Test java/lang/instrument/RetransformWithMethodParametersTest.java is failing
Reviewed-by: sspitsyn, dcubed, lmesnik
1 parent f5e0870 commit 95fd9d2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
 

‎test/jdk/java/lang/instrument/RetransformWithMethodParametersTest.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import java.io.File;
3636
import java.io.FileOutputStream;
3737
import java.lang.instrument.ClassFileTransformer;
38-
import java.lang.reflect.Method;
38+
import java.lang.reflect.Executable;
3939
import java.lang.reflect.Parameter;
4040
import java.nio.file.Files;
4141
import java.nio.file.Paths;
@@ -59,7 +59,8 @@
5959
class MethodParametersTarget {
6060
// The class contains the only method, so we don't have issue with method sorting
6161
// and ClassFileReconstituter should restore the same bytes as original classbytes.
62-
public void method1(
62+
// This method should be ctor, otherwise default ctor will be implicitly declared.
63+
public MethodParametersTarget(
6364
int intParam1, String stringParam1 // @1 commentout
6465
// @1 uncomment int intParam2, String stringParam2
6566
)
@@ -99,8 +100,8 @@ private void log(Object o) {
99100

100101
private Parameter[] getTargetMethodParameters() throws ClassNotFoundException {
101102
Class cls = Class.forName(targetClassName);
102-
// the class contains 1 method (method1)
103-
Method method = cls.getDeclaredMethods()[0];
103+
// the class contains 1 method (ctor)
104+
Executable method = cls.getDeclaredConstructors()[0];
104105
Parameter[] params = method.getParameters();
105106
log("Params of " + method.getName() + " method (" + params.length + "):");
106107
for (int i = 0; i < params.length; i++) {
@@ -174,7 +175,7 @@ private void compareClassBytes(byte[] expected, byte[] actual) throws Exception
174175
}
175176
log("Class bytes are different.");
176177
printDisassembled("expected", expected);
177-
printDisassembled("expected", actual);
178+
printDisassembled("actual", actual);
178179
fail(targetClassName + " did not match .class file");
179180
}
180181

0 commit comments

Comments
 (0)