Skip to content

Commit

Permalink
Fix private
Browse files Browse the repository at this point in the history
  • Loading branch information
biboudis committed Jul 2, 2024
1 parent 32cca7c commit ad8bf16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ public Object[] invoke(Object matchCandidate)
String underlyingName = mangle(this.getDeclaringClass(), Arrays.stream(getPatternBindings()).map(pb -> pb.getType()).toArray(Class[]::new));

try {
Method method = this.getDeclaringClass().getMethod(underlyingName, matchCandidate.getClass());

Method method = this.getDeclaringClass().getDeclaredMethod(underlyingName, matchCandidate.getClass());
method.setAccessible(override);
Object carrier = method.invoke(matchCandidate, matchCandidate);

Class<?>[] bindingClasses = Arrays.stream(this.getPatternBindings()).map(d -> d.getType()).toArray(Class[]::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
* @test
* @summary SimpleDeconstructorsTest
* @enablePreview
* @compile --enable-preview --source ${jdk.version} -parameters SimpleDeconstructorsTest.java
* @run main/othervm --enable-preview SimpleDeconstructorsTest
*/

Expand Down Expand Up @@ -191,14 +190,16 @@ public static class Bug {
public Bug(int i) {
this.i = i;
}
public pattern Bug(int i) {
private pattern Bug(int i) {
match Bug(this.i);
}
}

public static void testGetDeclaredDeconstructors_bug3() throws IllegalAccessException {
var b = new Bug(2);
var x = Bug.class.getDeclaredDeconstructors()[0].invoke(b);
Deconstructor<?> declaredDeconstructor = Bug.class.getDeclaredDeconstructors()[0];
declaredDeconstructor.setAccessible(true);
var x = declaredDeconstructor.invoke(b);
assertEquals(x[0], 2);
}

Expand Down

0 comments on commit ad8bf16

Please sign in to comment.